Support » Theme: Chaplin » Trouble adding new google font

  • Resolved gregjudall

    (@gregjudall)


    I’m trying to make use of the chaplin theme with a specific font from Google Fonts (Alata).

    So far I’ve enqueued the font from my child functions.php using:

    add_action( 'wp_enqueue_scripts', 'custom_add_google_fonts' );
    function custom_add_google_fonts() {
    	wp_enqueue_style( 'custom-google-fonts', 'https://fonts.googleapis.com/css?family=Alata&display=swap', false );
    	};

    Unfortunately, when I add a simple line to my child style.css to change the body text it refuses to override the parent.

    body{
           font-family: 'Alata', sans-serif;
    }

    Using the below works but I’d rather keep the parent theme in control, i.e. select the font from ‘Fonts’ section in the customise menu, which states “Chaplin supports all fonts on Google Fonts…”. Perhaps this isn’t possible?!?

    * {
         font-family: 'Alata', sans-serif;
    }

    I think it’s inheriting the theme font from elsewhere but it’s a little beyond me at this stage to determine exactly whats going on.

    Any help would be greatly appreciated.

    • This topic was modified 1 month ago by gregjudall.
    • This topic was modified 1 month ago by gregjudall.
    • This topic was modified 1 month ago by gregjudall.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Theme Author Anders Norén

    (@anlino)

    Hi @gregjudall,

    Alata works fine for me when I add it in Customizer → Fonts, when running Chaplin as well as a Chaplin child theme. The Google Fonts CSS is enqueued as a dependency for the Chaplin parent theme stylesheet, so it’s possible that the enqueue has been dropped if you have modified the enqueues in your child theme.

    Try setting Alata as the body font in the Customizer → Fonts panel and temporarily remove all enqueue code from your child theme, and check if that resolves the issue. If it does, there’s something in the child theme enqueues that cause the Google Fonts stylesheet to be dropped.

    — Anders

    Thanks for getting back in touch. Just before you replied I realised I could manually type in ‘Alata’ in the customiser for the header but NOT the body, although it was not present in the drop down selection boxes.

    Actually, this is good enough for what I need. Would be handy for it to be in the drop down but this is by no means essential.

    More pressing than this however is the fact I just updated the parent theme to 2.1.1 and now I’m getting a critical error!

    Parse error: syntax error, unexpected ‘)’ in D:\Websites\htdocs\mountaindogmotorcycles.com\wp-content\themes\chaplin\functions.php on line 357

    Theme Author Anders Norén

    (@anlino)

    @gregjudall I’ve submitted another update which should hopefully fix the issue, although it doesn’t occur on my local, so it’s hard to troubleshoot. Which version of PHP are you running? You can find it on Tools → Site Health → Info → Server.

    Still no joy.

    I’m running PHP 7.1.33

    Also selecting preview for the chaplin theme on the wordpress.org site is giving me:

    There has been a critical error on your website.

    If I try and preview another theme, i.e. twentytwenty, it loads without problem.

    Theme Author Anders Norén

    (@anlino)

    Darn it. I managed to reply the issue and fix it in version 2.1.3, which was just submitted. Let me know if it works. Really sorry for the trouble.

    Hey, no worries, thanks for being so responsive! I’m working locally anyway so no bother for me. I’m locked out of WP because of the error but once the theme on wordpress.org is updated to 2.1.3 I’ll update and test.

    Great, we’re back! 2.1.3 is working for me.

    Many thanks, and great work!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.