Gutenbergのカスタム投稿でカテゴリーが出ない場合
function.phpをいじって自前でカスタム投稿タイプを作成し、自前のカスタム投稿用のカテゴリー(カスタムタクソノミー)作成しましたが、記事編集画面にが出ませんでした。
‘show_in_rest’をtrueにする
カスタム投稿タイプでGutenbergを有効にする場合はregister_post_type()のオプションで’show_in_rest’ を trueにする必要がありますが、register_taxonomyも同様にオプションでshow_in_restをtrueにする必要がありました。
register_taxonomy(
'your_custom_taxonomy',
'your_custom_post',
array(
'hierarchical' => true,
'label' => 'カスタムタクソノミー',
'public' => true,
'show_ui' => true,
'show_in_rest' => true, //これが必要
)
);
いくつかのサイトはGutenberg導入前の記事が多いので、この’show_in_rest’について記載されていないことが多かったです。(参考になったのは英語のgithub issue)
参考 Custom Taxonomies Don’t Show in the sidebar