3

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!

  • 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
7

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
    );
}
|improve this answer|||||
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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