I created a custom post type named portfolio with tag taxonomy support.
Since WP does not make a difference between post tags and custom post type tags, I created a menu item Taxonomy under which I want to put categories and post tags. I managed to create the the menu and submenus, and also remove category and post tags from the Post menu, but i didn't manage to remove Post Tags from the custom post type menu.
I tried:
remove_submenu_page( 'edit.php?post_type=portfolio', 'edit-tags.php?taxonomy=post_tag&post_type=portfolio' );
You can use remove_submenu_page()
- the trick however is to get the slug exactly right, to do this the easiest way is to dump the global $submenu and check for the menu_slug and submenu_slug.
global $submenu;
var_dump($submenu);
This will give you the array of menus, the top level key is the menu_slug and then the correct submenu_slug can be found in the element 2 of the nested arrays.
So if I had a custom post type called "my_events" and I wanted to remove the tags menu from it, my original menu structure would look like this
...
'edit.php?post_type=my_events' =>
array
5 =>
array
0 => string 'All Events' (length=10)
1 => string 'edit_posts' (length=10)
2 => string 'edit.php?post_type=my_events' (length=28)
10 =>
array
0 => string 'Add New' (length=7)
1 => string 'edit_posts' (length=10)
2 => string 'post-new.php?post_type=my_events' (length=32)
15 =>
array
0 => string 'Tags' (length=4)
1 => string 'manage_categories' (length=17)
2 => string 'edit-tags.php?taxonomy=post_tag&post_type=my_events' (length=55)
...
From this you can see that the menu_slug is 'edit.php?post_type=my_events'
and the submenu slug for the tags menu is 'edit-tags.php?taxonomy=post_tag&post_type=my_events'
.
So the remove function call would be:
remove_submenu_page('edit.php?post_type=my_events', 'edit-tags.php?taxonomy=post_tag&post_type=my_events');
Note that the submenu slug is html encoded so the ampersand is now &
- this is probably that thing that has made it hard for people to work out from first principles what the slug name should be.