1. HOME
  2. WordPress
  3. 固定ページやカスタム投稿ページでGutenberg(ブロックエディタ)を無効化する
WordPress - 2020-08-22

固定ページやカスタム投稿ページでGutenberg(ブロックエディタ)を無効化する

固定ページやカスタム投稿ページでGutenbergを無効化したい場合はfunctions.phpに下記のように記述します。

固定ページの場合

add_filter( 'use_block_editor_for_post_type', 'hide_block_editor', 10, 10 );
function hide_block_editor( $use_block_editor, $post_type ) {
  if ( $post_type === 'page' ) return false;
  return $use_block_editor;
}
PHP

カスタム投稿ページの場合

カスタム投稿のスラッグ名「sample」とします

add_filter( 'use_block_editor_for_post_type', 'hide_block_editor', 10, 10 );
function hide_block_editor( $use_block_editor, $post_type ) {
  if ( $post_type === 'sample' ) return false;
  return $use_block_editor;
}
PHP