[英]How can I hide admin bar from my wordpress theme site while I'm logged in to customize it?
I am new in wordpress. 我是wordpress的新手。 Need some help here,I want to remove wordpress admin bar from my website but not from admin panel to have a look for my website will look while I will publish.
需要一些帮助,我想从我的网站删除wordpress管理栏,但不是从管理面板删除看看我的网站将在我发布时查看。
How can I do that? 我怎样才能做到这一点?
From your theme directory open function.php file and add the below code. 从你的主题目录打开function.php文件并添加以下代码。 Hope your problem will solve.
希望你的问题能解决。
add_filter('show_admin_bar', '__return_false');
If you want to hide it for all the users then paste this code into functions.php of your theme. 如果要为所有用户隐藏它,请将此代码粘贴到主题的functions.php中。
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
Or if you want to hide it for all the users except admin,then you need to add this code into funtions.php 或者,如果要为除admin之外的所有用户隐藏它,则需要将此代码添加到funtions.php中
show_admin_bar(false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.