WordPress6.1删除前端页面classic-themes.min.css样式文件调用

2023-05-2108:14:30网站管理维护Comments1,276 views字数 622阅读模式

WordPress更新到6.1版本后,WordPress会自动生成并在前端head中引用一个ID为classic-theme-styles-css的classic-themes.min.css样式文件,文件里包含了一个class选择器.wp-block-button__link的样式代码,看上去似乎是作用于古腾堡区块之类的,如果觉得自己用不到,或者感觉到碍眼,可以通过wp_enqueue_scripts钩子删除。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/wg/40893.html

生成的调用代码如下:

1
<link rel='stylesheet' id='classic-theme-styles-css' href='http://www.boke8.net/wp-includes/css/classic-themes.min.css?ver=6.2' type='text/css' media='all' />

删除classic-theme-styles-css的方法:

在主题的functions.php文件添加下面的代码文章源自菜鸟学院-https://www.cainiaoxueyuan.com/wg/40893.html

1
2
3
4
5
function remove_block_library_css() {
	wp_deregister_style('classic-theme-styles');	
	wp_dequeue_style('classic-theme-styles');
}
add_action( 'wp_enqueue_scripts', 'remove_block_library_css', 100 );

保存即可。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/wg/40893.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/wg/40893.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定