Archived topic
Missing Google Fonts from Font selector
3 replies · Started by Morten on December 17, 2020
Hi!
First of all, I've searched the forum for solutions to this issue and I found the following support topic:
https://docs.generatepress.com/article/customizing-the-google-font-list/
Unfortunately this doesnt seem to work for my installation of GeneratePress. I've added the
specified code to my child theme, but it doesnt seem to change anything in the theme font selector.
Hi Martin,
Since the documentation is pretty dated, I've actually tested this snippet included on the docs to check and make sure.
add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
$fonts[ 'david_libre' ] = array(
'name' => 'David Libre',
'variants' => array( '400', '500', '700' ),
'category' => 'serif'
);
return $fonts;
}
And it actually still works as shown here: https://share.getcloudapp.com/llun66Nj
Note: I'm using Code Snippets plugin but adding this to the Child Theme's functions.php should do the same thing.
Can you recheck the snippet if there's no missing syntax? Let us know.
You can link us to the site you're working on if you'd like. You can provide the site details on the private information text field.
I think I've found the issue. The snippet to add all the Google Fonts doesn't work, but I got the snippet you just posted working for the one font I actually needed.
Here's the added code that worked for anyone interested:
add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
$fonts[ 'mulish' ] = array(
'name' => 'Mulish',
'variants' => array( '400', '500', '700' ),
'category' => 'sans-serif'
);
return $fonts;
}
I think I’ve found the issue. The snippet to add all the Google Fonts doesn’t work, but I got the snippet you just posted working for the one font I actually needed.
Nice one! Good catch. :D
Glad you were able to make it work. :)