Hide the Admin Bar in WordPress

By  on  

WordPress automatically injects an admin toolbar at the top of the page for logged in users.  This bar is really an annoyance to me because it slightly throws off my theme design and I never need the toolbar for anything.  Here's a snippet of code which will prevent that toolbar from displaying:

add_filter('show_admin_bar', '__return_false');

Now I don't need to hide this toolbar with CSS and my layout can look as it should. I love WordPress' filtering/hook system!

Recent Features

  • By
    5 Ways that CSS and JavaScript Interact That You May Not Know About

    CSS and JavaScript:  the lines seemingly get blurred by each browser release.  They have always done a very different job but in the end they are both front-end technologies so they need do need to work closely.  We have our .js files and our .css, but...

  • By
    Serving Fonts from CDN

    For maximum performance, we all know we must put our assets on CDN (another domain).  Along with those assets are custom web fonts.  Unfortunately custom web fonts via CDN (or any cross-domain font request) don't work in Firefox or Internet Explorer (correctly so, by spec) though...

Incredible Demos

  • By
    CSS Triangles

    I was recently redesigning my website and wanted to create tooltips.  Making that was easy but I also wanted my tooltips to feature the a triangular pointer.  I'm a disaster when it comes to images and the prospect of needing to make an image for...

  • By
    MooTools Typewriter Effect Plugin Upgrade

    Last week I shared my MooTools Typewriter Class with you. It was pretty well received and I got a few feature requests that I've implemented including "backspacing" and character variance delays. I'm not going to explain the old code, so click here...


  1. I thought there was a setting in WordPress to disable that feature, but I’m not entirely sure. But I agree with you, the admin bar is quite the annoyance.

  2. Or log out and visit your domain…

    It annoys me, too. With this snippet deployed I’m guessing you bookmark `wp-admin` to get back to the dashboard.

  3. You can do this from the dashboard.

    Users>your profile > uncheck Show Toolbar when viewing site

    • Vishal

      That’s the way!

    • Glenn

      BIngo! Atta boy Ahmed.

    • Nicholas

      Thanks for explaining the correct way! I’ve been searching for this fix for days.

  4. I quite like the bar, but I hide it for all users who can’t edit posts (the thing it’s most useful for).

    add_action('set_current_user', 'csstricks_hide_admin_bar');
    function csstricks_hide_admin_bar() {
      if (!current_user_can('edit_posts')) {
    • I’m building a dev site for my company. Where do I include the code snippet you’ve shared?

    • Naresh Devineni

      Inside your theme’s functions.php file

  5. Thanks for the snippet, however for users who do not like code play – there is an in-built option in profile settings to hide the admin bar.

    While “Chris Coyier” modification is for sure useful in multi-user setup!

  6. This simple snippet will go into my WordPress core settings file as I find it a pain to have to disable the bar (users -> your profile – > show toolbar) with each new install. Thanks for sharing the snippet.

  7. Milagros Pérez

    David and Chris, thanks!

    This is just what I was looking for :)

  8. I prefer to use the below code in ‘functions.php’ to hide admin bar.

    if (!current_user_can(‘edit_posts’)) {
    • Thanks Chankey Pathak,it’s working nicely :)

  9. Thanks Chankey, that did the trick.

  10. I never found the admin bar of much use. Disabling it is the first thing I do after setting up a new WordPress site.

  11. I found the suggestion here leaves a 28px space at the top of my custom theme pages. The following snippet/filter removes it completely. Put it into functions.php in your theme.

    function my_function_admin_bar(){ return false; }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');
    • @adam It worked perfectly! Thank you!

  12. Miikey


    thx for the solution, That’s what I was looking for.
    Greetz Miikey

  13. The bar is helpful in editing posts. I just use incognito if I want to test the design without the bar. It’s also helpful in making sure there are any other admin-specific things on the page.

    But another reason to remove the admin bar that was not mentioned in the page: when you want to cache the site to be used by a reverse proxy like cloudflare – you don’t want the admin bar to show…

  14. You can also add this to your functions.php file

  15. “You can do this from the dashboard.

    Users>your profile > uncheck Show Toolbar when viewing site”

    Thanks Ahmed – two second job!

    That bar always annoyed me when I’m logged in and checking CSS

  16. Also you can use this code, it will hide admin bar to users that can not manage options

    if ( ! current_user_can( 'manage_options' ) ) {
        show_admin_bar( false );
    • @Carlos It worked perfectly. Thanks!

  17. But, if there is no toolbar – how user will log-off?

    Also, how to make members to log-in but not to get “admin” page, just to be able to see pages which are protected for members?

    • Dan

      Create a logout page?

  18. Patricia

    This extension works great! You just need to install :)


  19. Aayushi Jain, how could that possibly have worked?

    I noticed Chris Coyer and Chankey essentially posted the same bit of code, and it is wrong:

    [code redacted, read next comment]

    As it stands it is removing the header for users who can’t edit posts, and users who can’t edit posts do not have an admin bar.

    • Sorry it is waaay too late here.

      The incorrect code is:

      add_action('set_current_user', 'csstricks_hide_admin_bar');
      function csstricks_hide_admin_bar() {
        if (!current_user_can('edit_posts')) {

      The correct code is:

      add_action('set_current_user', 'csstricks_hide_admin_bar');
      function csstricks_hide_admin_bar() {
        if (current_user_can('edit_posts')) {

      The difference is the “!” operator.

  20. Yes. it is very annoying. Thanks for the code. I will surely try this.

  21. Another thanks to Ahmed – I searched high and low for the answer to this – and I hate adding code and messing with stuff like that where a simple 3 second fix like that exists!

  22. This has been so helpful so many times, thanks!

  23. Jay

    How do you hide it only for mobile users with screen size less than 1200px?

  24. Charl

    I have this on my child theme’s functions.php and it doesn’t seem to work. Am I missing something?

    add_action('set_current_user', 'remove_admin_bar');
    function remove_admin_bar() {
    	if ( current_user_can( 'manage_options' ) ) {
    • Charl, you need to use !current_user_can() This is because the ! means not, at the moment users who can manage options have the bar hidden. Please note that I have not explored the wordpress API

    • Charl

      Thanks! That worked.

  25. How do I remove menu admin bar in wp-admin ?

    • What you need is this:

      function hide_admin() {
      	if (!current_user_can('update_core') || is_admin()) {
      add_action('set_current_user', 'hide_admin');
  26. Donny

    if you guys don’t want to edit codes, just open new private window (Safari & Firefox) or new incognito window (chrome).

    Then swap between admin window (with wp admin bar) for editing, and guest window (without wp admin bar) to do live testing.

  27. I am using the latest version of WP…and the Nav bar is displayed when you are on the website. You don’t need to signin. I am using a premium theme and I installed buddypress and now I have 2 sets of login/register link displayed on the top left of my screen.

  28. Dan

    its not working anymore in wordpress 4.4, how do i fix it?

  29. Fabrício Batista Rocha


Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!