admin管理员组文章数量:1130349
I registered a new taxonomy:
function all_about() {
register_taxonomy( 'all_about',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => false, /* if this is false, it acts like tags */
'labels' => array(
'name' => 'Categorization', /* name of the custom taxonomy */
'singular_name' => 'Name', /* single taxonomy name */
'search_items' => ' Search', /* search title for taxomony */
'all_items' => 'All items', /* all title for taxonomies */
'parent_item' => 'Parent item', /* parent title for taxonomy */
'parent_item_colon' => 'Parent item colon:', /* parent taxonomy title */
'edit_item' => 'Edit', /* edit custom taxonomy title */
'update_item' => 'Update', /* update title for taxonomy */
'add_new_item' => 'Add new', /* add new title for taxonomy */
'new_item_name' => 'New title' /* name title for taxonomy */
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'all-about', 'with_front' => false ),
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
)
);
}
add_action( 'init', 'all_about' );
Works ok:
Now I need select this new taxonomy here at the same way I can select the tags:
How can I do this?
I registered a new taxonomy:
function all_about() {
register_taxonomy( 'all_about',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => false, /* if this is false, it acts like tags */
'labels' => array(
'name' => 'Categorization', /* name of the custom taxonomy */
'singular_name' => 'Name', /* single taxonomy name */
'search_items' => ' Search', /* search title for taxomony */
'all_items' => 'All items', /* all title for taxonomies */
'parent_item' => 'Parent item', /* parent title for taxonomy */
'parent_item_colon' => 'Parent item colon:', /* parent taxonomy title */
'edit_item' => 'Edit', /* edit custom taxonomy title */
'update_item' => 'Update', /* update title for taxonomy */
'add_new_item' => 'Add new', /* add new title for taxonomy */
'new_item_name' => 'New title' /* name title for taxonomy */
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'all-about', 'with_front' => false ),
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
)
);
}
add_action( 'init', 'all_about' );
Works ok:
Now I need select this new taxonomy here at the same way I can select the tags:
How can I do this?
Share Improve this question edited Jan 3, 2019 at 22:48 Howdy_McGee♦ 20.9k24 gold badges91 silver badges177 bronze badges asked Jan 3, 2019 at 17:59 rafaelfndevrafaelfndev 2272 silver badges10 bronze badges1 Answer
Reset to default 3The reason it does not show up automatically is because it requires REST enabled to display. By default, show_in_rest is set to false when registering taxonomies and post types. There's currently a Trac Ticket #42785 open to change this default functionality.
So in short when registering a taxonomy while using the Block Editor you'll need to explicitly say: 'show_in_rest' => true
function all_about() {
register_taxonomy( 'all_about',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => false, /* if this is false, it acts like tags */
'labels' => array(
'name' => 'Categorization', /* name of the custom taxonomy */
'singular_name' => 'Name', /* single taxonomy name */
'search_items' => ' Search', /* search title for taxomony */
'all_items' => 'All items', /* all title for taxonomies */
'parent_item' => 'Parent item', /* parent title for taxonomy */
'parent_item_colon' => 'Parent item colon:', /* parent taxonomy title */
'edit_item' => 'Edit', /* edit custom taxonomy title */
'update_item' => 'Update', /* update title for taxonomy */
'add_new_item' => 'Add new', /* add new title for taxonomy */
'new_item_name' => 'New title' /* name title for taxonomy */
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'all-about', 'with_front' => false ),
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
'show_in_rest' => true,
)
);
}
add_action( 'init', 'all_about' );
I registered a new taxonomy:
function all_about() {
register_taxonomy( 'all_about',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => false, /* if this is false, it acts like tags */
'labels' => array(
'name' => 'Categorization', /* name of the custom taxonomy */
'singular_name' => 'Name', /* single taxonomy name */
'search_items' => ' Search', /* search title for taxomony */
'all_items' => 'All items', /* all title for taxonomies */
'parent_item' => 'Parent item', /* parent title for taxonomy */
'parent_item_colon' => 'Parent item colon:', /* parent taxonomy title */
'edit_item' => 'Edit', /* edit custom taxonomy title */
'update_item' => 'Update', /* update title for taxonomy */
'add_new_item' => 'Add new', /* add new title for taxonomy */
'new_item_name' => 'New title' /* name title for taxonomy */
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'all-about', 'with_front' => false ),
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
)
);
}
add_action( 'init', 'all_about' );
Works ok:
Now I need select this new taxonomy here at the same way I can select the tags:
How can I do this?
I registered a new taxonomy:
function all_about() {
register_taxonomy( 'all_about',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => false, /* if this is false, it acts like tags */
'labels' => array(
'name' => 'Categorization', /* name of the custom taxonomy */
'singular_name' => 'Name', /* single taxonomy name */
'search_items' => ' Search', /* search title for taxomony */
'all_items' => 'All items', /* all title for taxonomies */
'parent_item' => 'Parent item', /* parent title for taxonomy */
'parent_item_colon' => 'Parent item colon:', /* parent taxonomy title */
'edit_item' => 'Edit', /* edit custom taxonomy title */
'update_item' => 'Update', /* update title for taxonomy */
'add_new_item' => 'Add new', /* add new title for taxonomy */
'new_item_name' => 'New title' /* name title for taxonomy */
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'all-about', 'with_front' => false ),
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
)
);
}
add_action( 'init', 'all_about' );
Works ok:
Now I need select this new taxonomy here at the same way I can select the tags:
How can I do this?
Share Improve this question edited Jan 3, 2019 at 22:48 Howdy_McGee♦ 20.9k24 gold badges91 silver badges177 bronze badges asked Jan 3, 2019 at 17:59 rafaelfndevrafaelfndev 2272 silver badges10 bronze badges1 Answer
Reset to default 3The reason it does not show up automatically is because it requires REST enabled to display. By default, show_in_rest is set to false when registering taxonomies and post types. There's currently a Trac Ticket #42785 open to change this default functionality.
So in short when registering a taxonomy while using the Block Editor you'll need to explicitly say: 'show_in_rest' => true
function all_about() {
register_taxonomy( 'all_about',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => false, /* if this is false, it acts like tags */
'labels' => array(
'name' => 'Categorization', /* name of the custom taxonomy */
'singular_name' => 'Name', /* single taxonomy name */
'search_items' => ' Search', /* search title for taxomony */
'all_items' => 'All items', /* all title for taxonomies */
'parent_item' => 'Parent item', /* parent title for taxonomy */
'parent_item_colon' => 'Parent item colon:', /* parent taxonomy title */
'edit_item' => 'Edit', /* edit custom taxonomy title */
'update_item' => 'Update', /* update title for taxonomy */
'add_new_item' => 'Add new', /* add new title for taxonomy */
'new_item_name' => 'New title' /* name title for taxonomy */
),
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'all-about', 'with_front' => false ),
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
'show_in_rest' => true,
)
);
}
add_action( 'init', 'all_about' );
本文标签: How to make a custom taxonomy selectable in post publish area
版权声明:本文标题:How to make a custom taxonomy selectable in post publish area? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749047329a2308071.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论