国内外主机
测评及优惠码

如何移出WordPress前端管理工具栏

显然,大多数的WordPress用户不喜欢看到网站前端的WordPress管理面板,当然也有很多去除前端管理面板的方法,比如之前WPMEE在这篇文章中介绍过的方法:如何在管理工具栏添加自定义链接,其中就涉及到如何移出前端管理工具栏,然而,他们只是禁用了管理栏,使管理栏的display:none,并没有将其中的JS,CSS完全移出。这里我们将告诉大家如何完全的移出WordPress前端管理工具栏包括JS,CSS代码等。
将下面的代码放到你主题的functions.php中就可以完全移出WordPress前端管理工具栏:

// Disable Admin Bar if (!function_exists('df_disable_admin_bar')) {     function df_disable_admin_bar() {         // for the admin page         remove_action('admin_footer', 'wp_admin_bar_render', 1000);         // for the front-end         remove_action('wp_footer', 'wp_admin_bar_render', 1000);         // css override for the admin page         function remove_admin_bar_style_backend() {             echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';         }         add_filter('admin_head','remove_admin_bar_style_backend');         // css override for the frontend         function remove_admin_bar_style_frontend() {             echo '<style type="text/css" media="screen">             html { margin-top: 0px !important; }             * html body { margin-top: 0px !important; }             </style>';         }         add_filter('wp_head','remove_admin_bar_style_frontend', 99);       } } add_action('init','df_disable_admin_bar');
好了,刷新下网页,看看管理面板使用的CSS已经JS是不是都没有了?
参考资料:http://www.trickspanda.com/2014/01/remove-wordpress-admin-bar/
赞一个
赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《如何移出WordPress前端管理工具栏》
文章链接:https://www.ibytx.com/1246.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

登录

找回密码

注册