admin管理员组文章数量:1290100
I have registered a custom tax to my CPT. On the edit screen the tax meta box appears with an autocomplete field.
Is it possible to display it as checkboxes or dropdown instead?
I have registered a custom tax to my CPT. On the edit screen the tax meta box appears with an autocomplete field.
Is it possible to display it as checkboxes or dropdown instead?
Share Improve this question asked Aug 7, 2013 at 17:34 Julian F. WeinertJulian F. Weinert 6002 gold badges5 silver badges18 bronze badges3 Answers
Reset to default 23You probably did not set the 'hierarchical' argument to true in your register_taxonomy. This would mean that it defaults to false, which gives you a tag-like interface.
Add 'hierarchical' => true
to your register_taxonomy.
As of WP 3.7 (https://core.trac.wordpress/ticket/14206) you can add this argument to register_taxonomy:
'meta_box_cb' => 'post_categories_meta_box'
to get the built-in checkbox category style metabox without having to make your taxonomy hierarchical.
Also you could instead provide your own callback function to create your own metabox (i.e. with a dropdown).
if you want to change the term of existing plugin to checkbox you need to edit the existing register_taxonomy().
add_action( 'init', 'change_room_term_to_checkbox', 999);
function change_room_term_to_checkbox()
{
$tax = get_taxonomy('roomtype');
$tax->meta_box_cb = 'post_categories_meta_box';
$tax->hierarchical = true;
}
'roomtype' is the name of term used on register_taxonomy('roomtype', array(.....
本文标签: Custom Taxonomy as checkbox or dropdown
版权声明:本文标题:Custom Taxonomy as checkbox or dropdown 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741489017a2381534.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论