admin管理员组

文章数量:1124539

I'm having an issue getting one of the google fonts to dequeue on my site

I've done all the reading, and I can see it needs to be dequeued after its been called, but before its been printed, but I cant figure out how to find that info?
I also cant work out which plugin is making the call?

This is the code I have put in my child functions.php

function remove_google_fonts_stylesheet() { 
    wp_dequeue_style( 'googleFontsOpenSans' );
    wp_dequeue_style( 'google-fonts-1' );
}
add_action( 'wp_enqueue_scripts', 'remove_google_fonts_stylesheet', 12 );

It worked great for the "opensans" font, but the "google-fonts-1" which is actually roboto, won't seem to go away no matter what changes I make.

I'm having an issue getting one of the google fonts to dequeue on my site https://subscriptionboxes.co.nz

I've done all the reading, and I can see it needs to be dequeued after its been called, but before its been printed, but I cant figure out how to find that info?
I also cant work out which plugin is making the call?

This is the code I have put in my child functions.php

function remove_google_fonts_stylesheet() { 
    wp_dequeue_style( 'googleFontsOpenSans' );
    wp_dequeue_style( 'google-fonts-1' );
}
add_action( 'wp_enqueue_scripts', 'remove_google_fonts_stylesheet', 12 );

It worked great for the "opensans" font, but the "google-fonts-1" which is actually roboto, won't seem to go away no matter what changes I make.

Share Improve this question edited Sep 14, 2021 at 9:04 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Sep 14, 2021 at 7:33 Subscription Box AustraliaSubscription Box Australia 1 4
  • You can always increase the priority of the action, third argument. To better understand how a equeue is called I would suggest using Query Monitor, the best plugin while developing in WordPress, among other things it can give you all handles of style/css and priority. – Buttered_Toast Commented Sep 14, 2021 at 7:50
  • There are styles that are registered, for that you would need to use wp_deregister_style, just add both, if changing the priority didn't help and you are sure that you have the correct handle. – Buttered_Toast Commented Sep 14, 2021 at 7:53
  • Thanks Buttered, ive installed query monitor, but i still cant work out how to find the culprit, or the priority. Yeah i forgot to mention i tried about 20 different priorities, from 1 to 10 to 999. I also tried the deregister thing ( i think i did it properly) and it made no change either. Im hoping someone can take 5 mins out of thier day to find this info for me, as its probably super easy for someone who knows. Thanks for your time mate – Subscription Box Australia Commented Sep 14, 2021 at 8:32
  • 1 all good i figured it out, a known issue here with elementor github.com/elementor/elementor/issues/4075 – Subscription Box Australia Commented Sep 14, 2021 at 9:23
Add a comment  | 

1 Answer 1

Reset to default 0

Probably, the font will be registered after wp_enqueue_scripts that you set is executed. To be sure, it is better to test the following code once:

add_action( 'wp_enqueue_scripts', 'remove_google_fonts_stylesheet', 999999);

本文标签: Google Font wont dequeue