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)
- 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 2568 times!