
2020.02.14
カスタム投稿にGutenbergを適用させる方法|WordPress

通常functions.phpでの設定でカスタム投稿を追加する場合、編集画面はGutenbergになっていません。
1行追記するだけで解決をしますので、以下に記します。
Contents
追記する一文
1 |
'show_in_rest' => true, |
挿入箇所についての記入例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// カスタム投稿タイプの追加 add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'sample', array( 'labels' => array( 'name' => __( '投稿サンプル' ) ), 'public' => true, 'menu_position' =>5, 'has_archive' => true, 'supports' => array('title', 'editor', 'thumbnail' ), 'show_in_rest' => true, ) ); flush_rewrite_rules( true ); } |