[Support request] Enqueue both google fonts and adobe typekit

Home Forums Support [Support request] Enqueue both google fonts and adobe typekit

Home Forums Support Enqueue both google fonts and adobe typekit

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1069090
    Heather

    I am using 3 different fonts that I am currently using a hook to bring the linksheets into the <head>, but I would like to enqueue these in my child theme instead.

    I know how to enqueue one google font, but not sure how to enqueue multiple font families in one function. My adobe typekit font is also a .css instead of a .js, so I can’t use enqueue scripts.

    Is there a function that can enqueue style all three of these? Or do I have to do them separately?

    #1069283
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You should be able to do something like this:

    add_action( 'wp_enqueue_scripts', function() {
        wp_enqueue_script( 'your-font-handle', 'URL TO YOUR SCRIPT' );
        wp_enqueue_script( 'another-handle', 'ANOTHER URL HERE' );
        wp_enqueue_style( 'one-more', 'URL TO THE CSS FILE' );
    } );

    Let me know if you need more info 🙂

    #1072575
    Heather

    So I believe all three are css style linksheets (2 google fonts and 1 adobe typekit), so I would just replace script with style?
    Also, I want it to live in my head, so under it would I add add_action wp_head() or something like that?

    #1073232
    Tom
    Lead Developer
    Lead Developer

    That’s right, you would use wp_enqueue_style in that case. No need to add anything to wp_head() here – you can just add the function I provided above using one of these methods: https://docs.generatepress.com/article/adding-php/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.