WPで「ホームページ」に指定した固定ページ編集画面のブロックエディター(コンテンツエディター?)を非表示にする方法を個人的メモ書きとしてここに記載しておきます。
動機:ACF(カスタムフィールド)を使う時に不要だったから
下記コードをfunctions.phpファイルに記述
function hide_editor_on_front_page() {
$post_id = $_GET['post'] ?? $_POST['post_ID'] ?? null;
if (!$post_id) return;
// フロントページのIDと一致してたら非表示にする
if ($post_id == get_option('page_on_front')) {
remove_post_type_support('page', 'editor');
}
}
add_action('admin_init', 'hide_editor_on_front_page');