WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a plugin that adds custom admin bar items, but I'd like them to appear all the way to the left. I know I can add and remove menu items with $wp_admin_bar->add_menu() etc, but how can I reorder them?

Edit: It looks like the admin bar menu item orders are defined in wp-includes/class-wp-admin-bar.php, but I can't figure out how to change this order from within my plugin function.

            add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );
            add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
            add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
            add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
share|improve this question
function custom_menu_order($menu_ord) {  
    if (!$menu_ord) return true;  

    return array(  
        'index.php', // Dashboard  
        'separator1', // First separator  
        'edit.php', // Posts  
        'upload.php', // Media  
        'link-manager.php', // Links  
        'edit.php?post_type=page', // Pages  
        'edit-comments.php', // Comments  
        'separator2', // Second separator  
        'themes.php', // Appearance  
        'plugins.php', // Plugins  
        'users.php', // Users  
        'tools.php', // Tools  
        'options-general.php', // Settings  
        'separator-last', // Last separator  
add_filter('custom_menu_order', 'custom_menu_order'); // Activate custom_menu_order  
add_filter('menu_order', 'custom_menu_order');  
share|improve this answer
It would add value to the solution if you present it with some explanations. – Maruti Mohanty Dec 9 '13 at 20:44
I tried echoing $menu_ord, but it doesn't return anything, so it might be empty. Also, my admin bar items are links with IDs, created with $wp_admin_bar->add_menu(), so I'm not sure I can reference them with a .php entry. – Jon Dec 10 '13 at 15:12
Does it work for any items starting with admin.php like admin.php?page=custom_settings_page? – Chittaranjan Dec 12 '13 at 13:19
Not helpful. This answer is about the admin menu. The question is about the Admin Bar. Different things. – Evan Mattson Sep 23 '14 at 4:42

Your Answer


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.