How do we hide the admin toolbar from the back end dashboard?
We can hide the toolbar when viewing the website with the below code but we want to also hide it from back end?
add_filter('show_admin_bar', '__return_false');
Thank you
How do we hide the admin toolbar from the back end dashboard?
We can hide the toolbar when viewing the website with the below code but we want to also hide it from back end?
add_filter('show_admin_bar', '__return_false');
Thank you
WordPress page for show_admin_bar
says:
You cannot turn off the toolbar on the WordPress dashboard
However, this trick works
function remove_admin_bar() { ?>
<style type="text/css">
body {
margin-top: -28px;
}
body.admin-bar #wphead {
padding-top: 0;
}
#wpadminbar {
display: none;
}
</style>
<?php }
add_action( 'admin_head', 'remove_admin_bar' );
In oreder to remove certain menus from admin bar use $wp_admin_bar->remove_menu($id);
where $id
of a specific menu can be found in Chrome Dev Tool. Each menus’ <li>
id in Dev tool is in the form of wp-admin-bar-{id}
, for example Comments menu has id wp-admin-bar-comments
. So to remove this menu code should be like this,
// remove links/menus from the admin bar
function my_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('comments');
// Code to remove other items goes here
....
....
}
add_action( 'wp_before_admin_bar_render', 'my_admin_bar_render' );