• Resolved Dawid

    (@dawidglobalsense)


    First of all, thank you for developing this great plugin.

    I recently realized that OMGF is unable to pull multiple fonts for me. For example:

    function add_google_fonts() {
    wp_enqueue_style( 'wpb-google-fonts', 'https://fonts.googleapis.com/css2?family=Heebo:wght@600&family=Mukta:wght@400;700&display=swap', false );
    }

    add_action( 'wp_enqueue_scripts', 'add_google_fonts' );

    This results in only one font being found, always the last one—in this case, Mukta.

    However, if I write my code this way, it is able to find all fonts:

    function add_google_fonts() {
    wp_enqueue_style( 'wpb-google-fonts', 'https://fonts.googleapis.com/css2?family=Heebo:wght@600', false );
    wp_enqueue_style( 'wpb-google-fonts-2', 'https://fonts.googleapis.com/css2?family=Mukta:wght@400;700', false );
    }

    add_action( 'wp_enqueue_scripts', 'add_google_fonts' );

    Am I doing something wrong? I am pretty sure it was working fine before. I started seeing this issue with new sites only.

    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author Daan from Daan.dev

    (@daanvandenbergh)

    This is a quirk in WordPress actually. wp_enqueue_style() cleans duplicate GET parameters, and technically, the family parameter is used multiple times when using the variable fonts (css2) API.

    You can either echo the stylesheet using e.g. the wp_head action and wrapping it in a <link/> element, or use the legacy Google Fonts API instead: https://fonts.googleapis.com/css?family=Heebo:600|Mukta:400,700

    Hope that helps!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.