WordPress 开放了会员注册以后,如果会员登陆,那么会在网页的顶部显示一个工具栏,方便显示网站后台的一些主题信息和会员登出操作,但是这样做以后我感觉比较烦,因为我的主题里面已经有这样的功能了,移除顶部的工具栏势在必行。
WordPress 中如果有会员登陆,那么会在每一页添加如下的代码:
- <style type="text/css" media="print">#wpadminbar { display:none; }</style>
- <style type="text/css" media="screen">
- html { margin-top: 32px !important; }
- * html body { margin-top: 32px !important; }
- @media screen and ( max-width: 782px ) {
- html { margin-top: 46px !important; }
- * html body { margin-top: 46px !important; }
- }
- </style>
那么可以通过在主题的 functions.php 中添加以下代码,来移除这段烦人的 CSS 样式:
- add_action('get_header', 'remove_admin_login_header');
- function remove_admin_login_header() {
- remove_action('wp_head', '_admin_bar_bump_cb');
- }
使用他,您的页面将变得更加的干净了。