How to Remove the WordPress Admin Bar

wpadminbar-180x180In the last days I had to remove the WordPress admin bar except for the administrators  for a customer of mine, because of this I thought that will be a good idea to share with you how this can be done.

To remove the WordPress admin bar you can use a plugin like: Global Hide/Remove Toolbar Plugin or you can use php code that can be added directly in the functions.php file of your theme.

Personally I prefer adding the code because it is very simple and it doesn’t create an necessary load to your site. Below is the code that can be added in the functions.php file for the specific tasks.

 

Remove WordPress Bar for All Users Except Aministarotors

If you want to do this then below is the code that you can use to do it:

 


add_action('init', 'remove_admin_bar');

function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
 show_admin_bar(false);
}
}

The above code added in the functions.php file will remove the WordPress admin bar for all users except administrators.

Remove WordPress Bar for All Users

If you really hate the admin bar and you want to disable it for all users then you must use the below cone in the functions.php file:


/* Disable WordPress Admin Bar for all users but admins. */
 show_admin_bar(false);

A short Video Tutorial

If you are a beginner and you don’t know how to add the below code in the function.php file then please see the below video:

 httpv://youtu.be/15HZ-ml6Glk

 

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>