Support » Developing with WordPress » How to use font variations

  • Resolved jccho96

    (@jccho96)


    Hello,

    I’m trying to change my woocommerce product titles to one of the variants that I’ve added in my global typography. I’m specifically using the EB Garamound font and I have Regular 400 Italic added as one of the variants.

    I’d like to change my product title to Regular 400 Italic but I’m having trouble doing so. If someone could please help me that would be greatly appreciated. Thank you so much

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • To change your WooCommerce product title to a specific variant of your global typography, you can add the following code snippet to your theme’s functions.php file:

    add_filter( 'the_title', 'change_product_title_font', 10, 2 );
    function change_product_title_font( $title, $post_id ) {
        if ( get_post_type( $post_id ) === 'product' ) {
            $title = '<span style="font-family: \'EB Garamond\', serif; font-weight: 400; font-style: italic;">' . $title . '</span>';
        }
        return $title;
    }
    

    This code will add the Regular 400 Italic variant of your EB Garamond font to your product titles. You can adjust the font-family, font-weight, and font-style values to match your specific typography variants.

    Thread Starter jccho96

    (@jccho96)

    Hi Linards,

    That worked, thank you sooo much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to use font variations’ is closed to new replies.