css - Genesis 框架中的 wp_dequeue_style 不起作用

标签 css wordpress genesis

我希望从我的子 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/

相关文章:

css - 如何将元素置于屏幕中央(无导航栏)

wordpress - Wordpress:你最喜欢的永久链接结构 - 高效/seo友好

php - Wordpress get_users() 通过比较查询返回所有用户

php - 带有 Bootstrap 的搜索结果页面中的 Wordpress 自定义布局

css - 如何简洁地编写此 javascript 来显示/隐藏元素列表?

jquery - 使表格适合特定宽度

javascript - 圆形按钮溢出的波纹效果

php - WooCommerce - 在添加到购物车事件中清空当前购物车

google-chrome - Genesis wordpress 主题中的 Cast_sender.js Chrome 扩展错误

javascript - 无法关闭 Genesis 主题中的粘滞消息