I was wondering if someone can help me with this. I’m currently following Shibashake’s tutorial about creating custom meta-boxes that include taxonomy selection here: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels .
They show how to remove the standard metabox WordPress automatically creates for taxonomies using the remove_meta_box function. Only problem is that the function for some reason doesn’t seem to work on taxonomies that work as categories ie ones where the hierarchical option is set to true. I know I have the function working because the ones set up as tags disappear easily enough. I can’t if it just isn’t possible or if there is something special I need to add in one of the parameters to make it work.
Example:
$args = array(
'hierarchical' => false,
'label' =>'People',
'query_var' => true,
'rewrite' => true
);
register_taxonomy('people', 'post',$args);
remove_meta_box('tagsdiv-people','post','side');
That works fine. If I set hierarchical to ‘true, however, the meta box stays put.
Can anyone shed some light?
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
Non-hierarchical taxonomies (like tags) use tagsdiv-{$tax_name}. Hierarchical taxonomies (like categories) use {$tax_name}div.
This is for historical reasons: categories were placed in categorydiv, tags in tagsdiv. When support for multiple non-hierarchical taxonomies was added, the tagsdiv name was expanded to tagsdiv-{$tax_name}. When finally multiple hierarchical taxonomies were made possible, they choose to generalize categorydiv to {$tax_name}div.
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