Remove default subpages from Custom Post Menu

I am creating a Custom Post Type using register_post_type. After running the function a new menu item appears in the Admin Panel.

Under this item there are menu items for new_item and all_items. Is there a way to get read of the these two options considering that I created a custom page to manage these posts.

2 Answers
2

You can manipulate the global variable $submenu and remove them. In normal circumstances, the index key values are 5 (All items) and 10 (New item). In this example, the post type is portfolio:

add_action( 'admin_init', 'remove_cpt_submenus_wpse_95797' );

function remove_cpt_submenus_wpse_95797()
{
    global $submenu;
    unset(
        $submenu['edit.php?post_type=portfolio'][5], 
        $submenu['edit.php?post_type=portfolio'][10] 
    );
}

Leave a Comment