Disable or Remove Admin Bar Toolbar From WordPress

The latest version of WordPress comes with an admin bar or toolbar. Admin bar, as the name suggests, is displayed on the top of your WordPress site and dashboard if you are logged in. It features some of the most frequently used tasks on it, based on which page you are.

There are some disadvantages of admin bar, for example, you cannot see the actual layout of your website, since it takes about 28px margin at top by adding this code to your site,

1
2
3
4
5
<style type="text/css" media="print">#wpadminbar { display:none; }</style>
<style type="text/css">
html { margin-top: 28px !important; }
* html body { margin-top: 28px !important; }
</style>

You may also want to disable the admin bar toolbar for your clients’ websites if you don’t want them to be performing admin functions on the site.

The method to disable or remove the admin bar from WordPress depends upon what you want to accomplish. You can disable the admin bar for a specific user by editing its user profile in WordPress dashboard. Just disable ‘Show toolbar when viewing site’ option.

If you have a multi-user WordPress site, and you think its cumbersome to remove admin bar toolbar from each user profile, you can simply disable globally from WordPress by adding this code into your functions.php file,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* Disable the Admin Bar Toolbar Globally by ThemePremium.com */
add_filter( 'show_admin_bar', '__return_false' );

<?php function themepremium_hide_admin_bar_settings() {
?>
    <style type="text/css">
        .show-admin-bar {
            display: none;
        }
    </style>
<?php
}

function themepremium_disable_admin_bar() {
    add_filter( 'show_admin_bar', '__return_false' );
    add_action( 'admin_print_scripts-profile.php',
         'themepremium_hide_admin_bar_settings' );
}
add_action( 'init', 'themepremium_disable_admin_bar' , 9 );

This code will disable the WordPress admin bar globally for every user on your WordPress site. Do let us know if you face any issues while removing the WordPress admin bar.