5

Now that wordpress 3.1 is out, where is the documentation for grouping custom post types together in the wp backend?

2
  • 1
    When you say group, what do you actually mean sorry? I'm not following. Do you mean relate post types to one another? Mar 13, 2011 at 2:47
  • But this method disappears submenu of custom post. Links for editing custom taxonomies are not present. How to do it and not lose this submenu? Jun 5, 2019 at 15:03

2 Answers 2

5

If you are wondering how to group multiple post types under one menu, you can easily do this with the show_in_menu argument when setting up your menu. See below:

$args = array(
 'public' => true,
 'show_ui' => true, 
 'query_var' => true,
 'rewrite' => true,
 'capability_type' => 'post',
 'hierarchical' => false,
 'show_in_menu' => 'your-custom-menu-slug.php',
 'menu_position' => null,
 'supports' => array('title','editor','custom-fields'),
 'has_archive' => true
);
register_post_type('your-post-type',$args);

Note: For this to work, show_ui must also be set to true.

Then you would create a menu using the add_menu_page function.

function add_your_menu() {
  add_menu_page( 'Multiple Post Types Page', 'Multiple Post Types', 'manage_options', 'your-custom-menu-slug.php', 'your_menu_function');
  // add_submenu_page() if you want subpages, but not necessary
}
add_action('admin_menu', 'add_your_menu');

In the same fashion, you can also attach post types to any existing menu. For example, it might be useful to attach certain post types to 'Posts' and others to 'Pages', while others might belong in 'Tools'. If you attach to an existing menu, you can ignore the add_menu_page function above and just modify the $args when registering your custom post type.

3
  • 1
    Thank for this answer. It work, but it only display all post of each custom post type and not display taxonomy(or category) of that of each custom post type. Can you help me, please? Thank you very much.
    – user25221
    Dec 26, 2012 at 4:54
  • Still one of the best and simplest answers. Works as expected.
    – marvinpoo
    Mar 18, 2019 at 12:48
  • Is there a way to show the CPT submenu options with this solution?
    – LTroya
    Nov 30, 2021 at 21:57
2

Just for future reference as this page ranks quite high in Google, you are not required to create a custom menu item if you just want to group some common post types together in the same menu, you can group together by using existing menu items:

By defining a 'master' post type, you can do something similar too:

'show_in_menu' => 'edit.php?post_type=a_master_post_type',
1
  • For that, you would need a hierarchy, while the accepted answer is more general.
    – marvinpoo
    Mar 18, 2019 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.