I’m trying to create a taxonomy that is sort of hidden.. meaning i intend to adjust the metabox so that you can only select a unique term from 3 options. “featured”,”normal” or “excluded”. but i can’t figure out how to remove the administration menu.
the following removes the Tags menu item from underneath Posts:
add_action('admin_menu','yoursite_admin_menu');
function yoursite_admin_menu() {
// remove_submenu_page was introduced in 3.1
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=post_tag' );
}
but this doesn’t remove the Featured taxonomy from underneath Portfolio
add_action('admin_menu','yoursite_admin_menu');
function yoursite_admin_menu() {
// remove_submenu_page was introduced in 3.1
remove_submenu_page( 'edit.php?post_type=portfolio', 'edit-tags.php?taxonomy=featured&post_type=portfolio' );
}
i’ve tried it a couple of different ways w/ regards to the slugs, but can’t get any of them to work. what am i missing?
You can use
remove_submenu_page()
, but getting the submenu slug correct is tricky and it has to be exactly right to work. The correct submenu_slug is not exactly the same as the link you click in the menu, the one in the menu is URL encoded but the slug itself is html encoded, the main difference being in the slug any&
chars will instead be&
In your example the function call should probably be:
To really get it right var_dump the submenu variable and you can see the actual slug in use by the system, see https://stackoverflow.com/questions/7610702/wordpress-remove-submenu-from-custom-post-type/ for a worked example.
This maybe old, and possibly even at the time of the original question not available but..
If you look in wp-includes/taxonomy.php there is a show_in_menu option for the register_taxonomy() hook that was left out of WordPress’s documentation.
Thought I would just leave this here for anyone looking for the answer 🙂
following Bainternet’s comment, i registered the taxonomy without showing any of the UI elements