I currently developing a wordpress plugin that is using two custom post types. What I want to know here: is it possible to add a custom post type menu as another custom post type’s sub menu?
3 comments
Comments are closed.
I currently developing a wordpress plugin that is using two custom post types. What I want to know here: is it possible to add a custom post type menu as another custom post type’s sub menu?
Comments are closed.
Yes. When you register your post type you need to set
show_in_menu
to the page you would like it displayed on.Adding a custom post type as a sub-menu of Posts
Here we set the “movies” post type to be included in the sub-menu under Posts.
If you have a taxonomy registered to the custom post type it will need to be added to the page as well.
In
add_submenu_page()
the first argument is the page to assign it to and the last is the menu slug.Adding a custom post type as a sub-menu of another custom post type
To add the pages to another custom post type include the post type’s query string parameter along with the page names.
To add the CPT Movies and its taxonomy Genre under the post type Entertainment adjust the code like this.
edit.php
becomesedit.php?post_type=entertainment
edit-tags.php
becomesedit-tags.php?taxonomy=genre&post_type=entertainment
Our custom post type:
Add him for existing Custom Post Type (“product” for example):
Or add for our custom plugin menu:
This is what worked for me
When I register the cpt ‘vrodos_game’ I set