建站教程

建站教程

Products

当前位置:首页 > 建站教程 >

删除 WordPress 管理栏 CSS

GG网络技术分享 2025-03-18 16:08 0


一两个版本,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');

}

用它。 别客气。

标签: WordPress 教程

提交需求或反馈

Demand feedback