我希望从我的子 genesis 主题中的重复 css 中清除我的代码。 一些插件使用相同的库但版本不同,例如 font-awesome。
如果你在这里看到 html 代码 www.cartomanziadivinazione.it 你可以看到:
<link rel='stylesheet' id='fontawesome-css' href='//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css?ver=1.3.9' type='text/css' media='all' />
我想删除这一行,我在函数主题中写了这个
add_action('wp_enqueue_scripts', 'cleaning_seo');
function cleaning_seo() {
wp_dequeue_style( 'fontawesome-css' );
wp_deregister_style( 'fontawesome-css' );
}
但是没有...
最佳答案
根据 codex :
Remove an enqueued script.
To be dequeued, the script must have been enqueued. Attempting to dequeue a script before the script is enqueued will have no effect.
因此,有可能您正试图在脚本排队之前将其从队列中取出。
确保您在正确的地方使用此功能;尝试增加执行顺序:
add_action('wp_enqueue_scripts', 'cleaning_seo', 999);
关于css - Genesis 框架中的 wp_dequeue_style 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38294437/