WordPress禁止所有人“浏览站点时显示工具栏”

wordpress顶部工具条(admin bar)如何去除,其实wordpress本意是为了方便站长快速的从前台进入后台来管理网站,但是这个由于它默认是对所有用户都显示的,所以看着也挺郁闷烦心的,那么那么怎么来去除这个烦人的工具条呢?灰牛通过搜索总结方法如下:How to remove the admin bar at the top of wordpress? In fact, wordpress is intended to facilitate the webmaster to quickly enter the background from the front desk to manage the website, but this is because it is displayed by default to all users, so it is very depressing and annoying to look at , Then how to remove this annoying toolbar? Grey Bull summarizes the method by searching as follows: 1. Disable the toolbar completely: 1-1 completely remove the wordpress toolbar (code 1)
show_admin_bar(false);1-2 completely remove the wordpress toolbar (code two)
add_filter(‘show_admin_bar’,’__return_false’);2. Display toolbar only for specific users 2-1 Display only for administratorsif (!current_user_can(‘manage_options’)) {add_filter(‘show_admin_bar’,’__return_false’); }[/ri-alerts]2-2 Only for administrators and editors if(!current_user_can(‘edit_posts’)) {add_filter(‘show_admin_bar’,’__return_false’); } 3. Move the toolbar from the top to the footer functionfb_move_admin_bar() {echo'< style type=”text/css”>body {margin-top: -28px;padding-bottom: 28px;}body.admin-bar #wphead {padding-top: 0;}body.admin-bar #footer {padding- bottom: 28px;}#wpadminbar {top: auto !important;bottom: 0;}#wpadminbar .quicklinks .menupop ul {bottom: 28px;}</style>’;}// If you want the toolbar to be displayed in the background At the top, please delete this line of code add_action(‘admin_head’,’fb_move_admin_bar’);//If you want the toolbar to be displayed at the top of the front desk, please delete this line of code add_action(‘wp_head’,’fb_move_admin_bar’); finally explain The reason why Gray Bull removed the administrator login toolbar is mainly because it is not very useful and occupies space to affect the appearance! Just put one of the above code options into the functions.php file of your theme, and you can easily solve this problem like a gray cow!
一、完全禁用工具条:
1-1完全去除wordpress工具条(代码一)

1-2完全去除wordpress工具条(代码二)

二、只对特定用户显示工具条
2-1只对管理员显示

2-2只对管理员和编辑显示

三、将工具条从顶部移至页脚

functionfb_move_admin_bar() {

echo’

<style type=”text/css”>

body {

margin-top: -28px;

padding-bottom: 28px;

}

body.admin-bar #wphead {

padding-top: 0;

}

body.admin-bar #footer {

padding-bottom: 28px;

}

#wpadminbar {

top: auto !important;

bottom: 0;

}

#wpadminbar .quicklinks .menupop ul {

bottom: 28px;

}

</style>’;

}

// 如果你想让工具条显示在后台顶部,请删除这行代码

add_action( ‘admin_head’, ‘fb_move_admin_bar’);

//如果你想让工具条显示在前台顶部,请删除这行代码

add_action( ‘wp_head’, ‘fb_move_admin_bar’);

 

最后解释下灰牛之所以去除管理员登录工具条,主要是因为它实用用处不大还占地方影响美观!将上面的代码选择其一方法放入到你主题的functions.php文件内即可,你也可以像灰牛一样轻松解决这个问题!
————————————————
版权声明:本文为CSDN博主「「已注销」」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_39086902/article/details/105524136

发表评论

后才能评论