カスタムフィールドの値を自動でタイトルに反映させたい
▽投稿画面の編集項目をカスタムフィールドの値のみ(お知らせ内容のテキスト)にしています。

▽タイトルがないので、(タイトルなし)となります。
そこで「カスタムフィールドの値を自動でタイトルに反映させたい」ということになりました。

functions.phpを編集
// wordpressでタイトルを空白で投稿した時に、自動的にタイトルを挿入する
// https://teratail.com/questions/38598
add_action('acf/save_post', 'replace_post_title');
function replace_post_title( $post_id ) {
// タイトルの入ったフィールドを取得
$newtitle = get_field("news_text",$post_id);
//タイトルが空でない場合は更新
if( $newtitle ) {
$args = array(
"ID"=>$post_id,
"post_title" => $newtitle
);
wp_update_post($args);
}
}
※news_textはフィールド名です↓

参考サイト
WordPressでカスタムフィールドを自動保存したい
https://teratail.com/questions/38598