The WordPress admin bar is a useful feature for when you’re managing your website. I tend to only find it useful, when I am working on the website. For example, most plugins use it for common features, such as a caching plugin using it to clear the cache.
If I am writing a post or just clicking around on a website as a user, the admin bar is clunky and annoying. Not only that but it slows down the website for something most users do not use.
When browsing a website as a user, I have never found the need to check the admin bar. No matter if I was logged in or not, simply because it is not a useful feature for me.
As a developer, the WordPress admin bar is great bridge between the admin panel and the front-end. For example, I can clear the cache with Autoptimize, use server-side caching, or access the customizer if needed.
But some website owners like to disable the WordPress admin bar for non-administrators. The following code will disable it.
This code can be added to the following places:
- functions.php file
- site-specific plugin
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'remove_admin_bar');
That’s all there is to it! Now any non-administrators will not have the WordPress admin bar appear when logged in. Administrators will still continue to see the admin bar.