How To Add Google Fonts in WordPress Theme

In this WordPress tutorial I will explain how to add Google Fonts in your WordPress theme.

Step 1: Select Google Fonts

Visit https://www.google.com/fonts and select fonts which you want to include in your theme. I have selected these two fonts.

  1. Open Sans
  2. Oswald

Step 2: Get Google Fonts Embed Code

After you have selected your Google Fonts, you will get embed code. It will be something like this.

<link href='https://fonts.googleapis.com/css?family=Open+Sans|Oswald' rel='stylesheet' type='text/css'>

Step 3: Add Codes in functions.php

Open functions.php file of your theme and add following codes.

function themename_google_fonts() {
  wp_enqueue_style( 'themename-googlefonts', '//fonts.googleapis.com/css?family=Open+Sans|Oswald');
}
add_action( 'wp_enqueue_scripts', 'themename_google_fonts' );

In above code change themename to your actual wordpress theme name. And Google Fonts url.

Step 4: Start using Google Fonts

Now you can use these Google Fonts in your theme.

font-family: 'Open Sans', sans-serif;
font-family: 'Oswald', sans-serif;

Hope this article helped you.