一两个版本之前,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>
呸。您可以使用以下代码删除此 CSS 和管理栏,这些代码应与您的 functions.php
文件放在一起:
add_action('get_header', 'remove_admin_login_header'); function remove_admin_login_header() { remove_action('wp_head', '_admin_bar_bump_cb'); }
使用它。不客气。