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;

Register the post type with show_ui set to false. Like this modified version of the sample in the Codex:

function codex_custom_init() {
  $labels = array(
    'name' => 'Books',
    'singular_name' => 'Book',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Book',
    'edit_item' => 'Edit Book',
    'new_item' => 'New Book',
    'all_items' => 'All Books',
    'view_item' => 'View Book',
    'search_items' => 'Search Books',
    'not_found' =>  'No books found',
    'not_found_in_trash' => 'No books found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Books'

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => false, // this is the change
    // 'show_in_menu' => true, // only works with show_ui true
    'query_var' => true,
    'rewrite' => array( 'slug' => 'book' ),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )

  register_post_type( 'book', $args );
add_action( 'init', 'codex_custom_init' );

Note: With ...

    'show_ui' => true,
    'show_in_menu' => false,

... you do not get the menu item but do get the management page if you navigate to the link, so you can remove it from the menu but still have a functioning default edit system if you want.


You said that you created a custom page to manage these posts. You must have also registered your own management page for that. I am not sure why you need the generated one. Put another way, I am not sure why you need to overhead of generating those default management pages only to remove the menus. However...

function remove_add_new_menu_wpse_94776() {

That is copied from another thread, as you can see from the numeric suffix on the function name. The above can cause the whole menu to collapse to the top level only, under the right circumstances, unless there is some other menu in place, which presumable you have but for completeness here is a sort-of dummy menu.

function remove_only_add_new_wpse_95797() {
  global $submenu;
function test_cb_wpse_95797() {
  echo 'hi';
  • hi! thanks for your response! it seems that these changes hide the menu item completely. I need the menu item header to be there with some other sub-pages I created. I just want to remove those default All Posts and Add new options
    – Ionut
    Commented Apr 14, 2013 at 19:16

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.