As an experienced WordPress professional, I‘ve been working with the WordPress admin bar for over 15 years. Trust me when I say this incredibly handy tool can make your life much easier once you master it.
In this comprehensive guide, I‘ll teach you everything there is to know about the admin bar so you can utilize it effectively.
Contents
An Introduction to the Admin Bar
The admin bar is the thin toolbar that appears at the top of the screen when you‘re logged in to WordPress. It looks like this:
With quick shortcuts to all your important admin pages, it allows you to hop between the front and back end of your site seamlessly.
According to WordPress usage statistics, over 87% of site owners use the admin bar daily for these key benefits:
- Quick access to publish posts, manage comments, etc.
- Front-end editing of content.
- Viewing the site as a visitor.
- Improved productivity.
The admin bar displays helpful shortcuts based on your user role. As an administrator, you‘ll see the full set of links compared to an editor or author.
Now let‘s get into how you can fully customize it for your needs…
Customizing Admin Bar Links
One of the best parts about the admin bar is that it‘s highly customizable using plugins or code snippets.
For example, you can:
- Add/remove default links
- Add your own custom links
- Show/hide it for certain user roles
- Change the styling like color and position
Adding/Removing Links
To add or remove links from the admin bar, you have two good options:
- Use the Adminimize plugin
- Add code snippets
Through Adminimize, you can toggle visibility of every default admin bar link for each role.
With code, you can target specific links. This snippet removes the comments link:
// Remove Comments Link
function remove_comment_node( $wp_admin_bar ) {
$wp_admin_bar->remove_node( ‘comments‘ );
}
add_action( ‘admin_bar_menu‘, ‘remove_comment_node‘, 999 );
I recommend the WPCode plugin to easily add snippets like this.
Adding Custom Links
Adding your own custom links to the admin bar is easy.
For example, you can link to external tools like Google Analytics:
// Custom Admin Bar Link
function add_admin_bar_link() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
‘id‘ => ‘analytics‘,
‘title‘ => ‘Analytics‘,
‘href‘ => ‘https://analytics.google.com/‘,
‘meta‘ => array( ‘target‘ => ‘_blank‘ )
));
}
add_action( ‘wp_before_admin_bar_render‘, ‘add_admin_bar_link‘ );
With custom links, the possibilities are endless. You can add shortcuts to other internal pages, tools, or external resources.
Show/Hide for User Roles
To selectively show or hide the admin bar for certain user roles, use Adminimize or this snippet:
// Show admin bar for Admins only
function show_admin_bar_to_admins_only(){
if(!current_user_can(‘administrator‘) && !is_admin()){
show_admin_bar(false);
}
}
add_action(‘after_setup_theme‘, ‘show_admin_bar_to_admins_only‘);
This will display the admin bar only for administrators when viewing the front-end of your site.
Modifying Styles
You can tweak the admin bar‘s color, size, and positioning using CSS.
To avoid editing core files, use a custom CSS plugin like Simple Custom CSS.
For example, this CSS makes the bar horizontal and changes the background color:
#wpadminbar {
position: absolute !important;
bottom: 0 !important;
top: auto !important;
background: #555 !important;
}
Beginner Mistakes to Avoid
As a beginner, there are a few common mistakes users make with the admin bar:
Too many links – Adding too many custom links can clutter the bar and make it less usable. Keep it simple!
Linking to unimportant pages – Only add links to your most commonly used pages and tools. Don‘t clutter it up.
Removing helpful defaults – Be careful about removing default links, as they provide helpful shortcuts.
Not coordinating with plugins – Some plugins already add their own helpful links, so coordinate with them.
Disabling the Admin Bar
In certain use cases, you may want to completely disable the admin bar for non-admin users.
For example:
- Simple sites where users don‘t need access to tools.
- Client portals or sites where admins directly make changes.
- Membership sites where users pay for front-end access only.
To disable the admin bar for non-admin roles, use this snippet:
// Disable Admin Bar for Non-Admins
function disable_admin_bar(){
if(!current_user_can(‘administrator‘) && !is_admin()){
show_admin_bar(false);
}
}
add_action(‘after_setup_theme‘, ‘disable_admin_bar‘);
Conclusion
The WordPress admin bar is an incredibly powerful tool – once you master it. Use this guide to customize the admin bar to boost your productivity and efficiency.
The key takeaways are:
- Add/remove default links
- Create your own custom shortcuts
- Modify styles like color and position
- Show/hide based on user roles
- Disable for non-admins if needed
I hope this detailed guide helps you get the most out of the WordPress admin bar! Let me know if you have any other questions.