0

I have enqueued google fonts in the usual way in functions.php:

function travellers_field_guide_scripts()
{
  wp_enqueue_style('travellers-field-guide-style', get_stylesheet_uri(), array(), _S_VERSION);
  wp_enqueue_style('googlefont_css', 'https://fonts.googleapis.com/css2?family=Alata&family=Lato:wght@300;400;700;900&display=swap', false);
}
add_action('wp_enqueue_scripts', 'travellers_field_guide_scripts');

However, upon checking the <head> all I see is this

<link rel="stylesheet" id="googlefont_css-css" href="https://fonts.googleapis.com/css2?family=Lato%3Awght%40300%3B400%3B700%3B900&amp;display=swap&amp;ver=5.4.2" media="all">

I've resorted to manually adding the link (exactly as I enqueued it) to the fonts in the header, and the fonts are downloaded as expected, but would be nice to know why Wordpress mangles the googlefont when trying to enqueue it. I checked my theme, there is no other reference to googlefont except to enqueue so I'm not doing anything to mangle it.

1

1 Answer 1

1

It looks like the URL is getting parsed somewhere and whatever does the parsing is probably internally only able to deal with one parameter for a particular name, so just keeps the second value for the family parameter.

As you have a valid usecase for having two parameters with the same name, you might want to file this as a bug.

If there are workarounds they could be hacky, so unfortunately adding to your header file might be the best solution for now, unless someone else can suggest another sensible way to add this to the header through hooks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.