Adding Google Fonts to Your WordPress Theme
Google Fonts is an often-used resource for enabling the use of additional fonts on websites. When using Google Fonts, Google gives you a couple of options for use including CSS import statements, Javascript and standard implementation via a link tag that looks something like:
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
Instead of dropping that tag with the <head> of your theme, the better approach would be to enqueue it with a function via your active theme’s functions.php file. You can do so with something similar to this:
function kf_load_fonts() { wp_register_style('googleFonts', 'https://fonts.googleapis.com/css?family=Open+Sans&display=swap'); wp_enqueue_style( 'googleFonts'); } add_action('wp_enqueue_scripts', 'kf_load_fonts');
Don’t forget to swap out the Google Fonts URL within the function with the one applicable to your font choices!