Archived topic
Google Font not adding to child theme
10 replies · Started by DM on June 4, 2021
Hi there.
I am trying to use a free google font in my child theme. I have added the google font so that it shows under the GP pull downs menus. When I try to assign it to h1, h2, h3 in the child theme, it does not work. Additionally, the font is a "cursive" category according to google even though it is actually a block upper font—Bebas Neue.
Can you help me?
Thanks!
DM
Hi there,
did you follow this guide and complete ALL the steps ?
No because I do not want to host it locally. It is already showing under the pull down menu. I don’t want to import it twice— or does it have to be??
You can't just add the CSS eg.
h1, h2, h3{
font-family: 'Bebas Neue', sans-serif;
}
That only applies a property - it won't make the request.
The Theme will automatically request the font if it is selected in the Customizer Typography settings.
As Bebas Neue is not included in the GP Google Font list, it needs to be added. This article explains how:
Then assign that font to the H1, H2, H3 in the Customizer, and it will make the request and apply the style.
Right—I know that it only applies the property in the child theme. I did not just try to use it in CSS. I already imported it in my functions:
add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
$fonts[ 'bebas_neue' ] = array(
'name' => 'Bebas Neue',
'variants' => array( '400'),
'category' => 'cursive'
);
return $fonts;
}
As I said, it is showing in the customizer list. What am I missing?
Have you selected the font for one of the headings or body ? It has to be selected for it to apply.
I’m setting the styles in the Child theme not in customizer.
Have you added anything to your functions.php to make the font request ?
That was it. Thanks!
Glad to be of help
Thanks!