enter image description hereI've just installed the Yoast SEO plugin and noticed that a new flyout menu was added to the admin bar once the plugin was activated.

Anyone know is there is a tutorial or example on how this is done?

  • A couple of related questions that may be of interest, here and here.
    – t31os
    Commented Dec 14, 2011 at 1:10

1 Answer 1


The action hook admin_bar_menu does the job. Here's what the comment in the core file says:

It includes the action "admin_bar_menu" which should be used to hook in and add new menus to the admin bar. That way you can be sure that you are adding at most optimal point, right before the admin bar is rendered. This also gives you access to the $post global, among others.


add_action('admin_bar_menu', 'add_items');

function add_items($admin_bar)
//echo "<pre>";
//echo "<pre>";

$admin_bar->add_menu( array(
    'id'    => 'my-item',
            'parent' => 'top-secondary',
    'title' => 'My Item',
    'href'  => '#',
    'meta'  => array(
        'title' => __('My Item'),
) );

You're gonna have to tweak a bit with it, because this code added the new item to the extreme left! I think examining the $admin_bar variable should give you an idea how to add an item.

Update: 'parent' => 'top-secondary' adds the item on the left of 'Howdy...'! So I bet there are other such position values. I'm looking for them ;)

Update 2: 'parent' => 'new-content' adds the item in the New > Post, Media etc menu.

Update 3: 'parent' => 'wp-logo-external' adds the item in the menu popped out from the WordPress logo on the extreme left.


I have written a blog post with all possible positions for the new item in the admin bar menu... If anyone interested please read here.

  • 1
    +1 Thanks. Adding 100,100 at the end of the action moves it to the right of the core menus.
    – Scott B
    Commented Dec 13, 2011 at 21:50
  • Awesome, thanks for the 100, 100 thing! I was wondering how to do that. Btw, I'm looking for more such position values, look for the updates in my answer ;) Commented Dec 13, 2011 at 21:51

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.