删除字体-非常棒的MaxCDN链接本地加载(&W)

时间:2019-01-11 作者:squidg

MaxCDN正在减慢我的网站速度,所以我想在本地加载font awesome,但我似乎无法编写正确的函数来删除它。

function remove_unwanted_css(){
wp_dequeue_style(‘font-awesome’, ‘https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css’);
}
add_filter(‘wp_print_styles’, ‘remove_unwanted_css’);

1 个回复
最合适的回答,由SO网友:Michael 整理而成

您必须在主题中找到已排队的样式表的名称,并使用该名称将样式出列-wp_dequeue_style. URL是不必要的。

示例:

function remove_unwanted_css() {
   wp_dequeue_style( \'font-awesome\' );
}
add_action( \'wp_print_styles\', \'remove_unwanted_css\', 100 );
或其他解决方案wp_deregister_style/:

add_action( \'wp_enqueue_scripts\', \'remove_default_stylesheet\', 20 );
function remove_default_stylesheet() {
    wp_dequeue_style( \'font-awesome\' );
    wp_deregister_style( \'font-awesome\' );

    wp_register_style( \'new-font-awesome\', get_stylesheet_directory_uri() . \'/new.css\', false, \'1.0.0\' ); 
    wp_enqueue_style( \'new-font-awesome\' );
}

相关推荐

如何在Functions.php中链接style.css

我是WordPress的新手;我刚开始学习WordPress。我想把风格联系起来。函数中的css。php,但我无法解决这里可能存在的问题。谁能给我指出正确的方向吗?指数php<?php get_header(); ?> <?php if ( have_posts() ) { while ( have_posts() ) { the_post();