How to Remove Admin Bar in WordPress


Are you tired of that admin bar in WordPress? Many have successfully disabled it so that it is effectively removed. It is automatically populated for all logged in users and can quickly throw off a theme. Many don’t ever even use the toolbar. Others just want to have it around for users that are editing content.

You don’t have to log out or go visit your domain to make this happen. One of the easiest ways to make this happen is by adding a specific snipped of code so that the toolbar will be prevented from displaying: add_filter(‘show_admin_bar’, ‘__return_false’). This makes it possible to hide the toolbar without using CSS and the layout of the theme still looks like it should.

This Can Also Be Accomplished From the Dashboard

If you don’t want to mess around with the coding at all, WordPress has also offered a setting within the dashboard that will disable the feature. Go to Users and then into your profile. You’ll then just need to remove the checkmark from the Show Toolbar option when viewing the site. This process has to be repeated for every new install that occurs, so multisite owners may opt to add coding instead of using the built-in option to save time over the long haul.

Sometimes, however, you’ll need to have some users who need to have access to the toolbar. If people can’t edit posts, they don’t really need to have the admin bar. This bit of code can be added to make sure users who do edit posts can access the admin bar to have their needs met.

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

You will need to add this bit of coding inside the php file of your theme’s function in order for it to work. It is not useful for users who are managing their content on their own, but in a multi-user setup, it can be a lifesaver. That’s because it will affect all users instead of requiring individualized updates.

Here’s Another Coding Option To Try

If you want to alter the code of your WordPress installation to remove the admin bar and you prefer a different solution, then try this bit of code instead. It’s a lot cleaner and easier to add without the additional needs in the four lines of code that are found above.

if (!current_user_can(‘edit_posts’)) {

Now some users have found that when they install the code into their site, an interesting side effect occurs. There may be a 28px space at the top of custom theme pages where the admin bar is hidden. What happens is that the bar disappears, but the spacing doesn’t resolve itself. You’ll want to include this bit of code to correct this problem if it occurs.

function my_function_admin_bar(){ return false; }
add_filter( ‘show_admin_bar’ , ‘my_function_admin_bar’);

This should remove the admin bar in WordPress for good or at least hide it from those who don’t edit posts. You can also change the “edit_posts” portion of the code for whatever user options are suitable for your multi-user needs and obtain similar results. It all just depends on what permissions have been assigned and how your users are accessing the dashboard to modify the site when needed.

If You Don’t Want To Do Any of This…

If you don’t like the idea of adding code to your WordPress site and the two-second check box solution doesn’t seem to be working for you for whatever reason, then there is a plugin available that will disable the WP admin bar for all user roles. The advantage of using the plugin is that it reduces memory consumption so that the control panel has a slightly faster perceived loading time.

The plugin that removes the admin bar can be run in one of two different ways. You can download and install it as you would any other plugin and it will run correctly. You can also put the single file from the download into the mu-plugins directory so that the removal function will be loaded by default without needing to be enabled.

If you don’t have a mu-plugins directory under wp-content, then you can create it and then place the plugin within the newly created directory.

Knowing how to remove the admin bar in WordPress is simple with these multiple solutions. Choose the one that makes the most sense for your site so that you and your users will be able to create and modify content as effectively as possible.