admin管理员组文章数量:1405553
I created a custom taxonomy and wanted to add it to the side-menu of my portfolio custom post type (in the admin area). My custom taxonomy is not loading, but the default one ('category') does. What did I miss?
add_action( 'init', 'add_taxonomies' );
function add_taxonomies() {
register_taxonomy(
'related_service',
'portfolio',
array(
'label' => 'Related Services',
'public' => true
)
);
}
add_action( 'init', 'register' );
function register() {
register_post_type( 'portfolio', array(
'label' => 'Portfolio',
'public' => true,
'show_in_rest' => true,
'taxonomies' => array( 'category', 'related_service' )
) );
}
I created a custom taxonomy and wanted to add it to the side-menu of my portfolio custom post type (in the admin area). My custom taxonomy is not loading, but the default one ('category') does. What did I miss?
add_action( 'init', 'add_taxonomies' );
function add_taxonomies() {
register_taxonomy(
'related_service',
'portfolio',
array(
'label' => 'Related Services',
'public' => true
)
);
}
add_action( 'init', 'register' );
function register() {
register_post_type( 'portfolio', array(
'label' => 'Portfolio',
'public' => true,
'show_in_rest' => true,
'taxonomies' => array( 'category', 'related_service' )
) );
}
Share
Improve this question
edited Dec 11, 2019 at 23:22
Rob Monhemius
asked Dec 11, 2019 at 22:04
Rob MonhemiusRob Monhemius
2032 silver badges6 bronze badges
5
|
1 Answer
Reset to default 0If you're using the Block Editor you also need to add 'show_in_rest' => true
for the taxonomy. You only have it for the CPT currently.
本文标签: How to add a custom taxonomy to a custom post type39s document tab
版权声明:本文标题:How to add a custom taxonomy to a custom post type's document tab 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744911157a2631925.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
'show_in_rest' => true
for the taxonomy. You only have it for the CPT currently. – WebElaine Commented Dec 11, 2019 at 22:36