How to Add Links to the WordPress Admin Bar / Toolbar


If you’d like to add links to your Admin Toolbar (formerly called the Admin Bar), then there are two ways you can go about that: You can use a plugin, or you can use code in your functions file. We’ll go over both ways below.

1. Plugin – Custom Admin Bar

Of course we need look no further than WPMU DEV’s own Custom Admin Bar plugin to do the trick of adding links to our Admin Toolbar.

This is a FREE plugin, but like all plugins from WPMU DEV, it sees regular updates to insure compatibility with the latest versions of WordPress.

The Custom Admin Bar plugin lets you …

  • Create dropdown menus
  • Use and image for a top menu item
  • Easily link to internal or external pages
  • Drag and drop menu items to sort them
  • Create a menu “hub” item that doesn’t link anyway but has sub-menu items that do

 

Here’s a look at adding a link.

First choose the type of link it is:

  • Link to an internal admin page
  • Link to internal Post or Page
  • Link to external site

 

Then add the name for the menu item and link for the page.

 

And here’s a look at the result.

Here’s a short video of the process to show you how quick and easy it is.

 

 

Featured Plugin - WordPress Facebook Plugin

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

 

2. Code in Functions File

If you’d like, you can also add new links to your Admin Toolbar by inserting code into your functions.php file. (Appearance > Editor > Theme Functions – functions.php) This doesn’t offer all the options the Custom Admin Bar plugin does, but it will add your links for you.

You will just need to fill in the code with your own information in various places where required.

add_action('admin_bar_menu', 'add_toolbar_items', 100);
function add_toolbar_items($admin_bar){
    $admin_bar->add_menu( array(
        'id'    => 'my-item',
        'title' => 'My Item',
        'href'  => '#',
        'meta'  => array(
            'title' => __('My Item'),            
        ),
    ));
    $admin_bar->add_menu( array(
        'id'    => 'my-sub-item',
        'parent' => 'my-item',
        'title' => 'My Sub Menu Item',
        'href'  => '#',
        'meta'  => array(
            'title' => __('My Sub Menu Item'),
            'target' => '_blank',
            'class' => 'my_menu_item_class'
        ),
    ));
    $admin_bar->add_menu( array(
        'id'    => 'my-second-sub-item',
        'parent' => 'my-item',
        'title' => 'My Second Sub Menu Item',
        'href'  => '#',
        'meta'  => array(
            'title' => __('My Second Sub Menu Item'),
            'target' => '_blank',
            'class' => 'my_menu_item_class'
        ),
    ));
}

 

Thanks to wp-snippets for this code.

Featured Plugin - WordPress Ecommerce Shopping Cart Plugin

Out of all the WordPress ecommerce plugins available, MarketPress has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more

Photo: Chain Link Close Up from BigStock

Tags

Comments (2)

Participate