I crete a custom post type with a taxonomy and all works fine.
WordPress create a main menu:
MyCustomPost
+----------> MyCustomPost
+----------> Add New
+----------> My Taxonomy
However, I like to create a my own menu, like this:
MyTitle
+----------> MyCustomPost
+----------> Add New
+----------> My Taxonomy
So, I create a my own menu:
$menu_main = add_menu_page( 'MyMenu', 'MyMenu', 'edit_posts', 'my_menu_key', array( $this, 'menu_main'), $icon_menu, 100 );
When register my custom post type I set show_in_menu
with my_menu_key
, and its works.
MyMenu
+----------> MyCustomPost
The question is: where is taxonomy? and `Add New sub menu?
Any idea?
Nice trick with
show_in_menu
. But the taxonomy sub-menu is built in a hard-coded manner andregister_taxonomy
doesn’t take any parameter like that. Probably, the Add New submenu works the same way.A workaround is to manipulate the
global $submenu
:Instead of manipulating the $submenu global, you can accomplish this by using built-in WordPress functions for better future compatibility.