可靠的WordPress服务商

WordPress 移除 head 代码 classic-theme-styles-inline-css 的方法

摘要:如果不能立即生效,多半是你的缓存插件或CDN需要清除一下缓存后再试

随着 WordPress 程序的不断更新,越来越多的冗余代码出现在了源码的 head 中,比如下面这块是自带的主题内联样式:

<style id="classic-theme-styles-inline-css">
/*! This file is auto-generated */
.wp-block-button__link{color:#fff;background-color:#32373c; ... ... ... ... }
/*# sourceURL=/wp-includes/css/classic-themes.min.css */
</style>

快速移除方法:

复制以下代码到主题的 functions.php 文件中的最后即可,

// 移除 classic-theme-styles-inline-css
add_action('wp_enqueue_scripts', function () {
    wp_dequeue_style('classic-theme-styles');
    wp_deregister_style('classic-theme-styles');
}, 100);

提示:如果不能立即生效,多半是你的缓存插件或CDN需要清除一下缓存后再试

本文属原创,转载请注明原文:https://themebetter.com/wordpress-remove-classic-theme-styles-inline-css.html

感觉很棒,欢迎打赏~

5 打赏
分享到:

评论 (0)

登录后评论
注:有关主题的售前售后请 提交工单

建站!你有充足的理由选择我们

世界上超过43%的网站是由WordPress搭建,而我们是国内最靠谱的WordPress主题开发商
在线工单