You may find that some of the themes you choose call out google fonts in the “old way”, but when you go to grab your fonts, it looks a tad different. One would think it was as simple as adding the “css2” to the front and the new family codes in the middle.
That’s not the case!
Instead, you need to add a little bit extra to the end. Here is a sample of the “old way” and the “new way” using a Genesis theme from Studiopress:
Old Way
add_action( 'wp_enqueue_scripts', 'agentpress_google_fonts' ); function agentpress_google_fonts() { wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:100,300,400,400i,700,700i|Libre+Caslon+Display&display=swap', array(), CHILD_THEME_VERSION ); }
New Way
add_action( 'wp_enqueue_scripts', 'agentpress_google_fonts' ); function agentpress_google_fonts() { wp_enqueue_style( 'google-font', '//fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,700;1,700&family=Libre+Caslon+Display&display=swap', array(), null ); }
Here, I added the entire information from google fonts … plus “array(), null ” and that did the TRICK!
Leave a Reply