WebCraft Tools

  • News
  • WordPress
    • WordPress Basics
    • WordPress Advanced
    • WordPress Performance
    • WordPress Security
    • WordPress Commerce
    • WordPress Troubleshooting
    • WordPress Themes
  • SEO and Analytics
WebCraft Tools › WordPress Advanced › Quickly add items to the Admin Toolbar

Quickly add items to the Admin Toolbar

Last updated on April 19, 2017 by Editorial Staff

Yesterday I shared how to remove items from the WordPress Admin Toolbar. This can be very useful but for someone who spends a lot of time logged into their website like myself, this tip can be even more useful. Here is the code.

[php]
add_action( ‘admin_bar_menu’, ‘my_toolbar_links_to_stuff’, 999 );
function my_toolbar_links_to_stuff( $wp_admin_bar ) {
if( current_user_can( ‘administrator’ ) ) :
$args = array(
‘id’ => ‘my_twitter’,
‘title’ => ‘Twitter’,
‘href’ => ‘http://twitter.com/#!/jameslaws’,
‘parent’ => ‘site-name’
);
$wp_admin_bar->add_node( $args );
endif;
}
[/php]

In the code above I’ve wrapped the call to add_node in an if statement so that it will only show for administrators. You could leave this out if you wanted it to show for everyone logged in. the code is pretty easy to follow and you could do as many of these as you need. Give your new menu item an ID, a title that will represent the link, the address you want the link to go to, and a parent ID if you want to show up under an already established menu item. If you set parent to false it will become the main menu item. You can visit my post about removing items from your admin toolbar for how to determine the menu items ID.

You are a busy person. How might you leverage this newly discovered power. Link to your social sites, Google Analytics, or your favorite web resources. You might even add links to pages within your admin that aren’t readily available from the front-end of your site.

How are using this on your sites? I would love to hear from you.

Tweet
Pin
Share
0 Shares

Filed Under: WordPress Advanced

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Site Links

  • Contact Us
  • Disclosure Statement
  • Privacy Policy

About WebCraft.tools

WebCraft.tools is your free resource for building, maintaining, and improving your WordPress website. Whether you are building your first site or have been building them for years, WebCraft.tools aims to provide you with tips, tricks, tutorials, and reviews to take your WordPress site to the next level.

© 2017 - 2026 · WebCraft Tools · Built by the WP Ninjas, LLC