Categories
WordPress

Show Admin Bar to Administrators only in WordPress

If you are using WordPress than you might be quite aware of the thing called Admin Bar. It is the bar that apears at the top of your WordPress site when you are logged in. Today I will tell you how to show this bar to admins only.

Why only admins?

  • If you have a multi author blog, then admin bar may have a bad impact
  • If you add any thing to admin bar, that is in relation to admin control you need to keep it secure
  • Admin bar sometimes messes up the layout so better remove it for non admins

How to do it?

Put this code in your activated theme's functions.php file & You are done

 

<?php
 
// Snippet code goes here!
if (!current_user_can('administrator')) :
  show_admin_bar(false);
endif;
 
?>
If hope you will Enjoy this snippet.
 

 

 

By Freakify Editorial

The post was written by the Freakify Editorial Team.

Freakify.com used to be managed by Awais, Maedah and their team before its acquisition.

2 replies on “Show Admin Bar to Administrators only in WordPress”

Hello Ahmad,
I like your blog’s post, every time i get new things to learn from your blog.

The above information is really helpful and i’ll surly try, if i get trouble then i’ll ask you.

Thanks for sharing with us. :)

Comments are closed.