最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp enqueue style - How to dequeue wp_get_custom_css in Twenty Twenty Theme

programmeradmin8浏览0评论

How to remove Additional CSS from loading. It loads as internal style sheet on every page. I am doing this but it is not working. if I

print_r(wp_get_custom_css()); It shows the same css. I want to disable it to load.

add_action( 'wp_enqueue_scripts', 'mywptheme_child_deregister_styles', 11 );
function mywptheme_child_deregister_styles() {
    wp_dequeue_style( 'wp-custom-css' );
 
}

How to remove Additional CSS from loading. It loads as internal style sheet on every page. I am doing this but it is not working. if I

print_r(wp_get_custom_css()); It shows the same css. I want to disable it to load.

add_action( 'wp_enqueue_scripts', 'mywptheme_child_deregister_styles', 11 );
function mywptheme_child_deregister_styles() {
    wp_dequeue_style( 'wp-custom-css' );
 
}

Share Improve this question edited Oct 7, 2020 at 6:45 Ahsan Najam asked Oct 7, 2020 at 5:55 Ahsan NajamAhsan Najam 1333 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

That style HTML is added by WordPress using wp_custom_css_cb() and it's hooked to wp_head like so:

add_action( 'wp_head', 'wp_custom_css_cb', 101 );

Which adds the custom/additional CSS in the document head.

So if you don't want that to happen — or you'd rather add/load the CSS manually, you can add this to your theme functions.php file:

remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
发布评论

评论列表(0)

  1. 暂无评论