How To Stop WordPress Admin Bar From Loading For All Non Administrators

Development 2 min read
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.
Scott Hartley

Scott Hartley

Founder & CEO, Sert Media

Founder and CEO of Sert Media, a Nashville-based digital marketing agency. Scott has spent over 15 years helping businesses grow through SEO, web performance optimization, and strategic digital marketing. His deep expertise in WordPress development, site speed, and technical SEO has guided hundreds of brands toward measurable results. When he's not auditing Core Web Vitals or refining campaign strategies, he's writing about the tools, techniques, and trends shaping the modern web.

Leave a Comment

Your email address will not be published. Required fields are marked with an asterisk.

Related Articles