How to Remove the Admin Bar from WordPress 3.1

You may have noticed that there is a new admin bar add to WordPress 3.1 that shows up when you are logged in as a subscriber or above. While I can see that this might be useful on some sites, for most this is just an annoyance and makes the site look too generically ‘WordPress’ or detracts from existing functionality that you may have added, such as search adaptations.

For example if you have a site that requires people to login before they can make a comment, or login before they can download, this will add to the screen a bunch of ugliness that is totally unwanted. Not to mention a bunch of scripts and codes that will slow the response time of your website.

So with that in mind I have created a bunch of samples that you can add to your functions.php (or header.php if you prefer) to remove this option.

For your functions.php

if (!is_admin() && !current_user_can('add_users')){
	wp_deregister_script( 'admin-bar' );
	wp_deregister_style( 'admin-bar' );

For your header.php

if (!current_user_can('add_users')){
 wp_deregister_script( 'admin-bar' );
 wp_deregister_style( 'admin-bar' );

Note: place just before <?php wp_head() ?> in header.php

I’ve only focused on the front-end user experience, rather than both the site and the admin pages.

Code break down….


!is_admin() checks if this is not an admin page


current_user_can('add_users') checks if the current user can add a user to the WordPress system, this only applies to administrators. So, !current_user_can('add_users') checks if the current user can not add new users, which means all other users. If you want to make the admin bar available to your authors and above then change ‘add_users‘ to ‘publish_posts‘. For a full list of capabilities check out this page on the WordPress Codex.

Do remember that roles and capabilities only apply to logged in users. If you don’t want to see the bar even as an administrator, then remove it from the if statement, or if you are doing this in the header.php remove the if statement all together, leaving it’s contents behind.

wp_deregister_script( ‘admin-bar’ );

wp_deregister_script( 'admin-bar' ); removes the Javascripts that are loaded for the admin bar.

wp_deregister_style( ‘admin-bar’ );

wp_deregister_style( 'admin-bar' ); removes the CSS file from being loaded for the admin bar, as we don’t need to style it.


remove_action('wp_footer','wp_admin_bar_render',1000); tells the system not to render the admin bar menu (html) when wp_footer is called, the value 1000 means run it after any other wp_footer action that has a lower value, the default is 10.

Want a plugin to do this?

There are a few plugins available to do this for you, BUT they will not be as efficient (read “will slow down your WordPress install silghtly more”) as putting this code directly into your header.php which is the most efficient placement as it only loads for front end pages, or in to your functions.php file which is the given standard. However, here are a list of plugins to do the job if your not confident with playing with php codes:

Admin Bar Disabler →
Custom Admin Bar →
Global Hide/Remove Admin Bar Plugin →
Admin Bar Removal →

Update with cleaner code

thanks to the lovely people at WPUA (WordPress Users Association) I’ve been given an even cleaner bit of code to replace the de-register script and styles and to get rid of the remove_action

add_filter( 'show_admin_bar', '__return_false' );

Of course you can still do all the same !is_admin or !current_user_can stuff if you like


  • thank you 

  • Dave Kingsnorth

    I have the exact same problem

  • JimmyJack

    Yes the cleaner code worked, and removed the css.

  • Khawar71

    To disable this feature, go to your WordPress’ Dasboard. On the “Users”
    section, click “Your Profile”. Then on the section the says “Show Admin
    Bar”, untick the box that says “when viewing site”. It should not have a
    check mark before you hit the “Update Profile” button.

  • just put this code in your theme’s functions.php and it will remove the admin bar completely. useful for some sites when you have everything at frontend and want to block access to dashboard :)


  • Renee

    simple solution. thanks!

  • this is in fact necessary to remove tha bar completely

  • Camera Coffee

    you edited the wrong file!

    it’s not



  • Viiratech

    Yeah this is a simple solution but I for site with several admins or sites that allow multiple members to log in then it might be just a too much work and putting in mind that some may not be so technical with wordpress.
    The easy way to go is adding the following code so that the admin bar  is disabled for all the users
    if(function_exists(‘show_admin_bar’)) :

  • Ddog5811

    Searched your site but could not find an answer to a related question – how do I permanently remove the New Feature balloons for all users? I have client Web site that I do not want these to appear on when I update it.

    I found this code “remove_action( ‘admin_enqueue_scripts’, array( ‘WP_Internal_Pointers’, ‘enqueue_scripts’ ) );” commented in the template.php file but when I uncomment it the dashboard goes blank.

    Questions why I want these balloons removed will be ignored.


  • andykillen

    I’ll take a look around for this and see what I can work out for you. I will come as a separate article.

  • Excellent piece of code. Better then the display:none I’ve seen around

  • Melindrea

    Very useful, especially since the only thing I wanted to do was to remove the loading of the CSS.

    I love the admin bar/toolbar, but the optimizer in me dislikes needing to override CSS I am not interested in, so this will allow me to restyle the bar to fit my wants/needs.

  • The best way I’ve found to remove that white space (it’s not caused by the admin bar) is to search out this css in style.css:

    #page {

    margin: 2em auto;

    max-width: 1000px;


    and switch the 2em to 0em or some variation of the same. That will remove the white space.