Remove Admin Bar Wordpress Front End

Leave a Comment

after_setup_theme Action Hook Wordpress:

After_setup_theme action hook of wordpress will help us to remove admin bar on the frontend of the wordpress. So please add  the following after_setup_theme action hook script in your functions.php file to remove admin bar from front end of wordpress theme.

Following script will remove the admin bar for non admin users, so please add in your functions.php file.

Script to remove admin bar Wordpress for Non Admin Users:


function admin_bar_remove() {
	if ( !is_admin() && !current_user_can('administrator')) {
	  show_admin_bar(false);
	}
}
add_action('after_setup_theme', 'admin_bar_remove');

Script to remove admin bar Wordpress for All Users:

function admin_bar_remove() {
      show_admin_bar(false);	
}
add_action('after_setup_theme', 'admin_bar_remove');

after_setup_theme Action Hook:

This action will be excuted on every page load, after the theme is initialized. With the help of this action hook we can perform the action which we need to perform after theme is loaded.


0 comments:

Post a Comment