Enqueueing Google Fonts In WordPress Method One

We as the developer as well as the designer all know that, when we are developing the WordPress theme or plugins, we may have to add the Google fonts for our project. So, how to add them in your project? Will it take much more long process? Will be be too hard to add it? Could it be just added in the header file of your theme? For all of the above answer is, it is very easy and will take small piece of time. So, for enqueueing Google fonts in your projects, may require these simple steps to be followed:

Find the Google Font in Google fonts directory

There are many of the Google fonts available in the Google font directory. So, visit that provided link earlier and then select the required one from the options and choose it. After your have chosen the required Google fonts for your site, now just lets move on and go to the next step.

Enqueue the Google Font

Now, since we are assuming that you have selected the required Google font for your project. Hence, now to enqueue the Google font in your project, you need to just add this below function in your theme’s functions.php file:

Here in the above example, we have enqueued the Open Sans Google font for our project. Here, the function to enqueue the Google font is by using the wp_enqueue_style function. Here, the first parameter to be used is the handle, and the second one is of the link to the Google font, provided by Google fonts itself. You need to just add the generated Google font link in it, when you generate the required Google font through its directory.

Note: All of the information on the Google Fonts to add in your project is provided in the Add this code to your website section there in the Google fonts page. So, do check it and modify the above example as it says, especially, the second one above, which links to that font.

Now, if you are successful in enqueueing Google Fonts in your site properly, then, we can assume that you are more familiar with it than before and can do it in the upcoming project of your without any misunderstanding. But, if you are still confused, then, do let us know from the comment box below and we will follow it up.

, , , , , , , , , , , , , , , , , ,

Post navigation

Bishal Napit

Bishal Napit is a WordPress theme developer from Tansen, Palpa, with a passion to learn more on WordPress.

Leave a Reply