0
votes

I have created a couple of custom post types in Wordpress that are loosely related - they aren't directly connected such as with a taxonomy, but from a UI perspective they should be on the admin side. Both custom post types are showing up in the admin area, however they are top-level items and I'd prefer to have them grouped under a master menu item like so:

  • Products (top level item)
    • All Products (first custom post type)
    • Product Groups (second custom post type)

While the two aren't directly related, it makes logical sense to group them together to help keep the admin area de-cluttered.

I've tried a couple of different things, but am certain it's a basic setting I'm not understanding. The most recent is the add_submenu_page option, but that doesn't seem to be working as I intended. Here is an example of the code:

add_action('admin_menu', 'create_child_menus');

function create_child_menus()
{
    add_submenu_page('products', 'Product Groups', 'Product Groups',     'manage_options', 'edit.php?post_type=product_groups');
}

Any ideas on how I can get a top-level grouping of admin items that contain multiple, non-related custom post types?

1

1 Answers

2
votes

I will assume you have custom posts types for 'products' and 'product_groups'.

When you register your 'product_groups' post type, use the following args:

'show_ui'              => true,
'show_in_menu'         => 'edit.php?post_type=products',

And do away with add_submenu_page()