简体   繁体   English

当我登录进行自定义时,如何从我的wordpress主题网站隐藏管理栏?

[英]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.

相关问题 如何从主题设置面板隐藏/显示 Wordpress 管理栏 - How to Hide / Show Wordpress Admin Bar from Theme Settings Panel 如何将登录用户的个人资料图片添加到我的 wordpress 站点上的 wordpress 顶部栏/菜单栏? - How do I add a logged-in users profile pic to the wordpress top-bar/menu-bar on my wordpress site? 我可以将网站复制到另一个域并在其上放置wordpress主题吗? - Can I copy my site to another domain and put wordpress theme on it? 如何将未登录Wordpress网站的用户重定向到特殊的登录页面? - How can I redirect users who are not logged in to my Wordpress site to a special login page? 如何在Wordpress主题的下拉菜单上隐藏图像? - How I can hide image on drop down menu in wordpress theme? 如何添加指向运行我的 onclick 函数的 Wordpress 管理栏的链接? - How can I add a link to the Wordpress Admin Bar that runs my function onclick? 我正在为 WordPress 创建自定义主题,如何显示我创建的“WordPress 页面”? - I'm creating a custom theme for WordPress, how can I show a “WordPress page” that I created? 当非管理员用户在管理面板中登录时,如何隐藏一些导航栏页面? - How can I hide some navbar pages when a non-admin user is logged-in in the admin panel? 如何将子菜单添加到WordPress管理栏 - How can I add a Submenu to the WordPress Admin Bar 如何删除水平滚动条Wordpress管理员编辑器 - How can i remove horizontal scroll bar wordpress admin editor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM