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 have a site with eight custom post types. Each is registered with 'menu_position' => 5 (below the Post menu). A side effect of having more than four CPTs is that the Media menu now appears in the middle of the list of CPTs (see image).

Admin menu with many custom post types

My solution is to duplicate the Media menu item in a lower position, then unset the original Media menu item:

add_action( 'admin_head', 'change_menu_items' );

function change_menu_items() {

    global $menu;

    $menu[14] = $menu[10];
    unset( $menu[10] );

}

My question is: is this likely to cause any unforeseen side effects? I haven't come across any yet, but just wanted to make sure.

Thanks!

share|improve this question
    
I don't see any drawback. You are only changing the position of the menu. It's a link to another page. –  keatch Feb 25 '11 at 23:03
add comment

1 Answer

up vote 7 down vote accepted

this might work:

add_filter('custom_menu_order', 'my_custom_menu_order');
add_filter('menu_order', 'my_custom_menu_order');

function my_custom_menu_order($menu_ord) {
    if (!$menu_ord) return true;
    return array(
        'index.php', // the dashboard link
        'edit.php?post_type=custom_post_type',
        'edit.php?post_type=page', 
        'edit.php' // posts
            // add anything else you want, just get the url
    );
}
share|improve this answer
    
thanks, i didn't know about that filter. –  Simon Blackbourn Feb 27 '11 at 12:41
    
Fantastic solution, and so easy! Curious, any way to control or remove the separators that Wordpress places in the menu as well? (they seem to be more obvious when the menu is collapsed) –  Mr.Brown Jul 11 '12 at 2:32
add comment

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.