WordPress Custom Post Type with Custom Menu

I’ve successfully created a custom post type called ‘mycustompost’ for a WordPress plugin I’m developing and added it as a submenu item instead of a top menu.

The navigation structure works until you try to add or edit the custom post, at which point the navigation doesn’t have the parent menu open, but the submenu is selected.

Read More

My question is how do I tell WordPress that all mycustompost pages (view/add/edit/delete) should set the mycustompost parent menu as active?

Here’s a cut down version of the code I’m using.

$supports = array('title', 'editor', 'revisions');
      register_post_type( 'mycustompost',
        array(
          'labels' => $labels,
          'public' => true,
          'exclude_from_search' => true,
          'publicly_queryable' => false,
          'supports' => $supports,
          'show_in_menu' => false,
          'show_ui' => true,
        )
      );

add_submenu_page($parent_menu["name"], 'My Custom Submenu', 'My Custom Submenu', $addon_menu["permission"], 'edit.php?post_type=mycustompost');

Related posts

Leave a Reply