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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You 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.
Method 2
As of WP 3.7 (https://core.trac.wordpress.org/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).
Method 3
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(…..
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0