Hide the Admin Bar in WordPress
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!
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...
Back in late 2012 it was not easy to find open source projects using requestAnimationFrame()
- this is the hook that allows Javascript code to synchronize with a web browser's native paint loop. Animations using this method can run at 60 fps and deliver fantastic...
I often incorporate tools into my customers' websites that allow them to have some control over the content on their website. When doing so, I offer some tips to my clients to help them keep their website in good shape. One of the tips...
Regardless of our position on vendor prefixes, we have to live with them and occasionally use them to make things work. These prefixes can be used in two formats: the CSS format (-moz-
, as in -moz-element
) and the JS format (navigator.mozApps
). The awesome X-Tag project has...
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.
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.
You can do this from the dashboard.
Users>your profile > uncheck Show Toolbar when viewing site
That’s the way!
BIngo! Atta boy Ahmed.
Thanks for explaining the correct way! I’ve been searching for this fix for days.
I quite like the bar, but I hide it for all users who can’t edit posts (the thing it’s most useful for).
I’m building a dev site for my company. Where do I include the code snippet you’ve shared?
Inside your theme’s functions.php file
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!
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.
David and Chris, thanks!
This is just what I was looking for :)
I prefer to use the below code in ‘functions.php’ to hide admin bar.
Thanks Chankey Pathak,it’s working nicely :)
Thanks Chankey, that did the trick.
I never found the admin bar of much use. Disabling it is the first thing I do after setting up a new WordPress site.
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.
@adam It worked perfectly! Thank you!
@adam
thx for the solution, That’s what I was looking for.
Greetz Miikey
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…
You can also add this to your functions.php file
“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
Also you can use this code, it will hide admin bar to users that can not manage options
@Carlos It worked perfectly. Thanks!
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?
Create a logout page?
This extension works great! You just need to install :)
http://wordpress.org/plugins/wp-admin-bar-removal/installation/
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:
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:
The correct code is:
The difference is the “!” operator.
Yes. it is very annoying. Thanks for the code. I will surely try this.
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!
This has been so helpful so many times, thanks!
How do you hide it only for mobile users with screen size less than 1200px?
I have this on my child theme’s functions.php and it doesn’t seem to work. Am I missing something?
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 APIThanks! That worked.
How do I remove menu admin bar in wp-admin ?
Thanks
What you need is this:
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.
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.
its not working anymore in wordpress 4.4, how do i fix it?
Thanks!!!