How to add google fonts to wordpress

  • Find right font

Access google fonts @ https://fonts.google.com/. You can browse or search to find the required font at this website.

  • Select the customisation as per your requirements.

Lets suppose you selected a font called “Crimson Text”. Click on “select this font” and it will open following window. please select the customisation required.

This will create a url, copy this url

 

  • Enqueueing google fonts in wordpress

Use the url copied in previous step and copy in into functions file with following code.

As you can see in below code, multiple fonts can be copied as below. In below function “Poppins” and “Crimson” is copied

function startwordpress_google_fonts() {
wp_register_style('Poppins', 'https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700');
wp_enqueue_style( 'Poppins');
wp_register_style('Crimson', 'https://fonts.googleapis.com/css?family=Crimson+Text:400,400i,600,600i,700');
wp_enqueue_style( 'Crimson'); 
}

add_action('wp_print_styles', 'startwordpress_google_fonts');

 

And you are all set. You can use this font in your world press CSS with the name that you have provided while registering this font. Normally you the same name while registering the font name to avoid the confusion.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.