• Skip to main content
  • Skip to primary sidebar
  • About
  • Contact
  • Resources
  • Blog
    • Easy Digital Downloads
    • General
    • Genesis Framework
    • jQuery/JavaScript
    • Project Management
    • WordPress Functions
    • WordPress Plugin Development
  • Army Lessons

Scott DeLuzio

WordPress Development Tutorials

WordPress Admin Bar Shortcuts

September 27, 2014 Scott DeLuzio Leave a Comment

WordPress is configured to display a toolbar at the top of the page to all logged in users by default. This toolbar provides a useful way for users to navigate through different areas of your site’s back end. However, some users might want custom shortcuts in WordPress admin bar, in order to quickly direct their users to different areas of the site.

Why add custom shortcuts in WordPress Admin Bar?

The WordPress admin bar will display links to frequently used administration screens, such as links to the Dashboard, new page or post editor, menus, etc.

Those links are useful to nearly everyone who runs a WordPress site. However, there are other links, which may be equally useful. For example, you might want quick links to news websites that your editorial staff frequently references or other areas on your site that might not be included in the standard admin bar links.

Add Custom Shortcuts in WordPress Admin Bar

In your child theme’s functions.php file, add the following code:

// add custom shortcut in the WordPress admin bar
function custom_shortcut_admin_bar($wp_shortcut) {
$args = array(
        'id' => 'wordpressorg',
        'title' => 'Visit WordPress.org',
        'href' => 'https://www.wordpress.org',
        'meta' => array(
                'class' => 'wordpressorg',
                'title' => 'Visit WordPress.org'
        )
);
$wp_shortcut->add_node($args);
}
add_action('admin_bar_menu', 'custom_shortcut_admin_bar', 999);

// add custom shortcut in the WordPress admin bar function custom_shortcut_admin_bar($wp_shortcut) { $args = array( 'id' => 'wordpressorg', 'title' => 'Visit WordPress.org', 'href' => 'https://www.wordpress.org', 'meta' => array( 'class' => 'wordpressorg', 'title' => 'Visit WordPress.org' ) ); $wp_shortcut->add_node($args); } add_action('admin_bar_menu', 'custom_shortcut_admin_bar', 999);

For your site, you will have to update the id, title, href, class, and title elements to whatever you need.

This code generates a link like this:
Custom shortcuts in WordPress admin bar

Drop-Down Multiple Custom Shortcuts

Let’s say that instead of just linking to WordPress.org from the WordPress admin bar, we want to link to the WordPress themes, plugins, support forum, and a sub-link to the Plugins and Hacks forum pages. It would be nice if those options dropped down under the current WordPress.org link, wouldn’t it?

To get this drop-down menu, we will expand upon the first code above.

// add custom shortcut drop-down in the WordPress admin bar
function custom_shortcut_admin_bar($wp_shortcut) {
// add the shortcut to WordPress.org
$args = array(
        'id' => 'wordpressorg',
        'title' => 'Visit WordPress.org',
        'href' => 'https://www.wordpress.org',
        'meta' => array(
                'class' => 'wordpressorg',
                'title' => 'Visit WordPress.org'
        )
);
$wp_shortcut->add_node($args);
 
// add the first child shortcut to WordPress themes page
$args = array(
        'id' => 'wordpressorg-themes',
        'title' => 'WordPress Themes',
        'href' => 'https://www.wordpress.org/themes',
        'parent' => 'wordpressorg',
        'meta' => array(
            'class' => 'wordpressorg-themes',
            'title' => 'Visit WordPress.org Themes'
            )
    );
    $wp_shortcut->add_node($args);
 
// add the second child shortcut to WordPress plugins page
$args = array(
        'id' => 'wordpressorg-plugins',
        'title' => 'WordPress Plugins',
        'href' => 'https://www.wordpress.org/plugins',
        'parent' => 'wordpressorg',
        'meta' => array(
            'class' => 'wordpressorg-plugins',
            'title' => 'Visit WordPress.org Plugins'
            )
    );
    $wp_shortcut->add_node($args);
 
// add the third child shortcut to WordPress support forum page
$args = array(
        'id' => 'wordpressorg-forum',
        'title' => 'WordPress Support Forum',
        'href' => 'https://www.wordpress.org/support',
        'parent' => 'wordpressorg',
        'meta' => array(
            'class' => 'wordpressorg-forum',
            'title' => 'Visit WordPress.org Support'
            )
    );
    $wp_shortcut->add_node($args);
 
// add a child shortcut under the WordPress support forum page to the Plugins and Hacks forum
$args = array(
        'id' => 'wordpressorg-forum-plugins-hacks',
        'title' => 'Plugins and Hacks',
        'href' => 'https://wordpress.org/support/forum/plugins-and-hacks',
        'parent' => 'wordpressorg-forum',
        'meta' => array(
            'class' => 'wordpressorg-forum-plugins-hacks',
            'title' => 'Visit WordPress.org Support Plugins and Hacks'
            )
    );
    $wp_shortcut->add_node($args);
}
add_action('admin_bar_menu', 'custom_shortcut_admin_bar', 999);

// add custom shortcut drop-down in the WordPress admin bar function custom_shortcut_admin_bar($wp_shortcut) { // add the shortcut to WordPress.org $args = array( 'id' => 'wordpressorg', 'title' => 'Visit WordPress.org', 'href' => 'https://www.wordpress.org', 'meta' => array( 'class' => 'wordpressorg', 'title' => 'Visit WordPress.org' ) ); $wp_shortcut->add_node($args); // add the first child shortcut to WordPress themes page $args = array( 'id' => 'wordpressorg-themes', 'title' => 'WordPress Themes', 'href' => 'https://www.wordpress.org/themes', 'parent' => 'wordpressorg', 'meta' => array( 'class' => 'wordpressorg-themes', 'title' => 'Visit WordPress.org Themes' ) ); $wp_shortcut->add_node($args); // add the second child shortcut to WordPress plugins page $args = array( 'id' => 'wordpressorg-plugins', 'title' => 'WordPress Plugins', 'href' => 'https://www.wordpress.org/plugins', 'parent' => 'wordpressorg', 'meta' => array( 'class' => 'wordpressorg-plugins', 'title' => 'Visit WordPress.org Plugins' ) ); $wp_shortcut->add_node($args); // add the third child shortcut to WordPress support forum page $args = array( 'id' => 'wordpressorg-forum', 'title' => 'WordPress Support Forum', 'href' => 'https://www.wordpress.org/support', 'parent' => 'wordpressorg', 'meta' => array( 'class' => 'wordpressorg-forum', 'title' => 'Visit WordPress.org Support' ) ); $wp_shortcut->add_node($args); // add a child shortcut under the WordPress support forum page to the Plugins and Hacks forum $args = array( 'id' => 'wordpressorg-forum-plugins-hacks', 'title' => 'Plugins and Hacks', 'href' => 'https://wordpress.org/support/forum/plugins-and-hacks', 'parent' => 'wordpressorg-forum', 'meta' => array( 'class' => 'wordpressorg-forum-plugins-hacks', 'title' => 'Visit WordPress.org Support Plugins and Hacks' ) ); $wp_shortcut->add_node($args); } add_action('admin_bar_menu', 'custom_shortcut_admin_bar', 999);

Add Custom WordPress Dropdown admin menu

Using the code above, we created the parent shortcut the same way we created the single link to WordPress.org originally. For each of the child shortcuts, we added a new 'parent' argument, which references the 'id' of the parent. In the case of the shortcuts to the Themes, Plugins, and Support Forum, the parent id was 'wordpressorg'. When we decided to add another level to the menu, the 'parent' argument we referenced referred to the id 'wordpressorg-forum', as the WordPress Support Forum was the next level up on our menu.

Disable WordPress Admin Bar

On some occasions, it might be necessary to disable the WordPress admin bar for all users except for administrators, or perhaps you might want to disable it altogether.

Once again we’re working in your child theme’s functions.php file.

To disable the WordPress admin bar for all users except for users with administrative privileges insert the following code:

add_action('after_setup_theme', 'disable_admin_bar');
 
function disable_admin_bar() {
if ( ! current_user_can( 'manage_options' ) ) {
    show_admin_bar( false );
}
}

add_action('after_setup_theme', 'disable_admin_bar'); function disable_admin_bar() { if ( ! current_user_can( 'manage_options' ) ) { show_admin_bar( false ); } }

To disable the admin bar for everyone including administrators, add this code instead:

show_admin_bar( false );

show_admin_bar( false );

You can also hide the WordPress admin bar on the front facing pages, while keeping it on the admin pages (dashboard, etc.) with:

add_filter('show_admin_bar', '__return_false');

add_filter('show_admin_bar', '__return_false');

WordPress Plugin Development Customize, Admin, Code, PHP, Users

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Come say hi!

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Tweets by scottdeluzio

My Products

Conditional Checkout FieldsFull Screen Background ImagesQuick CheckoutWP1099

I use affiliate links throughout this site and may earn a commission if you purchase through my links. I do not link to products or services that I do not trust, or use myself.
© 2025 · Scott DeLuzio · Built on the Genesis Framework