Site logo

Archived topic

Adding Google Font not working

6 replies · Started by Andy on July 19, 2020

Viewing posts 1–7 of 7

Hi,
I'm trying to add the google Manrope font (https://fonts.google.com/specimen/Manrope) to the font list but its not displaying. Following the documentation I've added the following script to my child theme functions file:

add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
	$fonts[ 'manrope' ] = array( 
		'name' => 'Manrope',
		'variants' => array( '300', '400', '500', '600', '700' ),
		'category' => 'sans-serif'
	);

	return $fonts;
}

Tried purging cache but nothing has helped.

Any help appreciated,

Thanks,

Andy

Hi there,

that function should work.
Can you try adding it using the Code Snippets plugin - if it still isn't displaying in the Customizer then something else must be conflicting.

Hmmm, tried adding it to the snippets plugin and it deactivated it giving this error:

The snippet has been deactivated due to an error on line 3:

Cannot redeclare function tu_add_google_fonts.

That means the tu_add_google_fonts function name is already being used.
Change both instances in your above function to something unique:

e.g

manrope_add_google_font

Hmmm, this is very odd. I changed the script as you suggested and I can actually see the font is being loaded in the source code but it's still not available in the Customizer or any Gutenburg Blocks including GenerateBlocks.

This is a new build so hardly has any plugins installed. I've even disabled Varnish Cache for the application but it hasn't helped.

I've edited my initial post and included the URL to the site.

I think it must have been some kind of cacheing issue as the fonts are loading now.

Glad to hear that

This archived topic is closed to new replies.