I choose Open Sans as my font for my site (as of writing this post). Now that I’ve created a child theme, I want to change the font. To do this, we will be working with our style.css and functions.php files within our child theme folder.
Update functions.php
function google_fonts() {
$query_args = array(
'family' => 'Open+Sans',
'subset' => 'latin,latin-ext',
);
wp_register_style( 'google_fonts', add_query_arg( $query_args, "//fonts.googleapis.com/css" ), array(), null );
}
add_action('wp_enqueue_scripts', 'google_fonts');
Update style.css
/* google font */
ul li {
font-family: open Sans, sans-serif;
}
p {
margin: 0 0 20px;
font-family: open Sans, sans-serif;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: open sans, sans-serif;
}
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Paragraph
One response to “WordPress Google Font with Child Theme”
Hi Tommy
I found that I had to do a wp_enqueue_style after the register line to get this to work. Took a while to figure this one out. Works nicely now.
Thanks for the article
Al