Categories: Wordpress Tricks

Hide Admin Bar while viewing site

If you are logged in the wordpress site and viewing the front pages you will see Admin bar on Top. Sometimes it looks odd to see  while viewing the site. Personally, I don’t find much use for it. I feel it’s just a ugly bar to me while admin bar shows at top of the page with only some of the options. So, I quickly come up with this solution to hide/remove the admin bar from the front end while visiting site.

 

  • From Admin Panel (Current User only)
– Go to Dashboard
– Click Users->Your profile
– Uncheck “Show Toolbar when viewing site”
– Update Profile

 

  • From function.php file
    -> insert the below code to function.php file
    add_filter('show_admin_bar', '__return_false');

OR, show_admin_bar(false);

OR use below code for all users who can’t edit posts

add_action('set_current_user', 'hide_admin_bar'); 
function hide_admin_bar() { 
if (!current_user_can('edit_posts')) { 
show_admin_bar(false); 
} 
}
  • From header.php file

-> insert the below code under wp_head() function

if ( is_user_logged_in()) {
?><style type="text/css">
#wpadminbar { display: none;}
</style>
<?php } ?>

 

Choose a suitable option to use in your site to implement. Further if you have any problem you are feel free to ask through comment.

This post has already been read 2596 times!

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

More Posts

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

Share
Published by
Mehedi Hasan
Tags: Wordpress

Recent Posts

WP Share A Friend – A Way to Capture Lead

What is Lead Capture: In general sense lead capture designates a process or way of…

5 years ago

Unlimited Modal POPUPS on MouseClick

Introduction Unlimited Modal POPUPS on MouseClick: Everyone knows about popup during site visits and most…

5 years ago

WordPress Pregnancy Calculator Plugin

Brief about Pregnancy Calculator : This WordPress Pregnancy Calculator plugin allows users to display an…

5 years ago

Interactive Service Plugin with Hover Effects VC

Introduction About this Service Plugin: This Visual Composer Service Plugin works as an addon to…

6 years ago

WP Dynamic Query String

Introduction of Dynamic Query String : This plugin allows user to set dynamic query string…

6 years ago

How to make scroll PDF in iFrame for iPAD Safari

There is an occasional bug for iPhone and iPad even they are designed as well and…

7 years ago