How to add font

I need to use the Times font family but cannot see it in the font manager. Can you tell me how I would add it in there, thanks.

Hi @waynepatt58,

Thanks for reaching out.

Are you referring to Lino type’s Times font family? Theme’s fonts are only limited to google font, system font, and Typekit fonts. Or perhaps, you can provide more details of what times font you’re referring?

Thanks!

Any font times family would be OK, will try Google just need to know how to install it and only apply it to certain posts, thanks

Hi Wayne,

You can add a google font by adding the code below in your child theme’s functions.php file.

function wpb_add_google_fonts() { 
    wp_enqueue_style( 'wpb-google-fonts', 'https://fonts.googleapis.com/css?family=Roboto', false ); 
}
 
add_action( 'wp_enqueue_scripts', 'wpb_add_google_fonts' );

Change the font https://fonts.googleapis.com/css?family=Roboto with the font that you like.

If you want to add a custom font, you can use @font-face

Please refer to the links below


Hope that helps.

just a quick question on your comprehensive reply. I do not want the font to be applied over the entire site, just to certain posts. Is that possible with your above recommendation?

Hi There,

It’s possible, please update the previous code to this:

function wpb_add_google_fonts() { 
	if( is_single(array(123, 456, 789)) )
    wp_enqueue_style( 'wpb-google-fonts', 'https://fonts.googleapis.com/css?family=Roboto', false ); 
}
 
add_action( 'wp_enqueue_scripts', 'wpb_add_google_fonts' );

The 123, 456, 789 should be your post IDs. To find your post ID, please take a look at this:

https://theme.co/apex/forum/t/setup-how-to-locate-post-ids/59

Hope it helps :slight_smile:

thanks, can we make the font just display on all posts, instead of entering ID?

Hey @waynepatt58,

You can remove the array inside the is_single() conditional. For more details, please see https://developer.wordpress.org/reference/functions/is_single/. You can see the rest of WordPress’ Conditional Tags at https://codex.wordpress.org/Conditional_Tags

Please just note that custom coding is outside the scope of our support. We will not support issues resulting from the use of our suggestion nor we will continually provide enhancements. From this point forward, I’d recommend that you learn from the links I’ve posted above.

Hope that helps and thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.