admin管理员组文章数量:1201412
I want to hide the admin bar from dashboard. I tried with following code:
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
It hide the admin bar when a logged in admin visit as front-end user. I actually want to hide the admin bar from dashboard back-end as indicated by red arrow in the following picture:
Any help is appreciated.
I want to hide the admin bar from dashboard. I tried with following code:
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
It hide the admin bar when a logged in admin visit as front-end user. I actually want to hide the admin bar from dashboard back-end as indicated by red arrow in the following picture:
Any help is appreciated.
Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked Jan 5, 2018 at 9:27 Abdus Sattar BhuiyanAbdus Sattar Bhuiyan 2232 silver badges16 bronze badges 1- 2 Does this answer your question? Remove top admin bar – T.Todua Commented May 14, 2020 at 20:31
1 Answer
Reset to default 3This might be not proper approach but this worked for me while testing. You can use these combinations to remove all links from Toolbar (admin-bar ) and then hide empty tool bar with css:
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo'); // Remove the WordPress logo
$wp_admin_bar->remove_menu('about'); // Remove the about WordPress link
$wp_admin_bar->remove_menu('wporg'); // Remove the WordPress.org link
$wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
$wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
$wp_admin_bar->remove_menu('feedback'); // Remove the feedback link
$wp_admin_bar->remove_menu('site-name'); // Remove the site name menu
$wp_admin_bar->remove_menu('view-site'); // Remove the view site link
$wp_admin_bar->remove_menu('updates'); // Remove the updates link
$wp_admin_bar->remove_menu('comments'); // Remove the comments link
$wp_admin_bar->remove_menu('new-content'); // Remove the content link
$wp_admin_bar->remove_menu('w3tc'); // If you use w3 total cache remove the performance link
$wp_admin_bar->remove_menu('my-account'); // Remove the user details tab
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );
function hide_admin_bar() { ?>
<style type="text/css">
#wpadminbar {
display: none;
}
</style>
<?php }
// on backend area
add_action( 'admin_head', 'hide_admin_bar' );
// on frontend area
add_action( 'wp_head', 'hide_admin_bar' );
For more details read this link
Out put is like below screenshot:
本文标签: Hide the wpadmin bar from dashboard
版权声明:本文标题:Hide the wp-admin bar from dashboard 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738591993a2101566.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论