Remove the Admin Bar in WordPress

Note to self.. Seen people talk about it. Seen people hack it. Seen people get crazy about it. The best (and only) way is:

add_filter( 'show_admin_bar', '__return_false' );

And if you’d like only Administrators (or Editors) to see it, but not regular users, with one slight modification:

if ( ! current_user_can( 'edit_posts' ) )
    add_filter( 'show_admin_bar', '__return_false' );

Okay, all this is “my humble opinion”, don’t take me too seriously. Interesting though how the admin bar can break the layout sometimes, especially with WP_DEBUG being switched on, but anyways, I was working on a real estate website last week, and fired the upgrade to WordPress 3.1 and then bam! Well I had to rewrite most of the code anyways since I was upgrading from WordPress 3.0-beta1. Seriously!

So I fixed my rewrites, my custom JOINs (by the way meta_query seems to now work just as fast as custom SQL JOINs when the meta table is indexed correctly), and my custom taxonomies. I saw the admin bar, I liked it, but hey, I’ve got a cool sign up and login forms there, with social logins as well, so it wouldn’t be very nice if the WordPress admin bar popped out to somebody looking to buy an expensive villa in Italy or Monaco ;)

So yah, use the code above in your functions.php file to get rid of the admin bar, others (through actions) tend to forget to remove some stylesheet or markup. Cheers!

3 thoughts on “Remove the Admin Bar in WordPress

  1. - WordPress News, Themes, Tutorials, Plugins, Questions, ...

  2. Hey, I think you can turn off the admin bar in the Profile setting in your Dashboard for all users.

Comments are closed.