麒麟吧

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

191 阅读
文章摘要

随着 WordPress 程序的不断更新,越来越多的冗余代码出现在了源码的 head 中,比如下面这块是自带的主题内联样式: style id=classic-theme-styles-inline-css /! This file is auto-generated / .wp-block-button__link{color:#fff;backg...

随着 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

分享到:

ArcticFox

人生短短几十年,不要给自己留下了什么遗憾,想笑就笑,想哭就哭,一件事,就算再美好,一旦没有结果,就不要再纠缠,久了你会倦,会累;一个人,就算再留念,如果你抓不住,就要适时放手,久了你会神伤,会心碎。

手机扫码阅读

微信或手机浏览器扫一扫,随时随地随心阅读与分享

收藏 0

发表评论