Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I was wondering for CPT list and editing pages to show under Posts tab instead of creating its own tab. I really want to use CPT (over using categories) because I'd have control over capability and different templates. Any input is appreciated.

share|improve this question
2  
Check this answer. I think it's exactly what you're asking for. And probably it's of better use here than there. If so, I'll delete it from there and post it here, as the OP said it didn't address his issue... –  brasofilo May 4 '13 at 12:20
    
Super, thanks @brasofilo –  Angela May 11 '13 at 3:35

1 Answer 1

up vote 0 down vote accepted

This can be done manipulating the global variable $submenu. In this example, the post type name is portfolio. See comments in code.

add_filter( 'custom_menu_order', 'move_one_post_type_wpse_98281' );

function move_one_post_type_wpse_98281( $menu_ord ) 
{
    global $submenu;
    // Enable the next line to inspect the $submenu values
    // echo '<pre>'.print_r($submenu,true).'</pre>';

    // Iterate through all submenu items
    foreach( $submenu['edit.php?post_type=portfolio'] as $add_submenu )
    {
        // Move it inside the Post post type menu
        $submenu['edit.php'][] = $add_submenu;
    }

    return $menu_ord;
}

Then, remove the menu item altogether:

add_action( 'admin_menu', 'remove_cpt_menu_wpse_98281', 15 );

function remove_cpt_menu_wpse_98281() 
{
    remove_menu_page( 'edit.php?post_type=portfolio' );
}

An in this example, we iterate through all post types that are public and not built-in and move the submenus inside the default Post post type.
And remove all menus with the same arguments.

Please, use this with care. In case of doubts/problems, use a One-by-One approach using the code above.

add_filter( 'custom_menu_order', 'move_all_post_types_wpse_98281' );
add_action( 'admin_menu', 'remove_all_cpt_menu_wpse_98281', 15 );

function move_all_post_types_wpse_98281( $menu_ord ) 
{
    global $submenu;
    $args=array(
      'public'   => true,
      '_builtin' => false
    ); 
    $post_types=get_post_types( $args );

    // Iterate through all post types
    foreach ($post_types as $post_type ) 
    {
        $cpt_submenu = 'edit.php?post_type=' . $post_type;
        foreach( $submenu[ $cpt_submenu ] as $add_submenu )
        {
            $submenu['edit.php'][] = $add_submenu;
        }
    }

    return $menu_ord;
}

function remove_all_cpt_menu_wpse_98281() 
{
    $args=array(
      'public'   => true,
      '_builtin' => false
    ); 
    $post_types=get_post_types( $args );
    foreach ($post_types  as $post_type ) 
    {
        remove_menu_page( 'edit.php?post_type=' . $post_type );
    } 
}

Results in the following. I'd remove the "Add new" from all post types, as there's already a shortcut in the main page of each:

result moving all CPT

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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