How can we help?

If you are looking for support for our PokaTheme, this is the place!

Home Forums PokaTheme support How to load google fonts locally instead of CDN

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #17847

    Hey there,

    using PK 4.04,

    Currently Google fonts are loaded from their CDNs

    <link rel=”preconnect” href=”https://fonts.googleapis.com”&gt;
    <link rel=”preconnect” href=”https://fonts.gstatic.com&#8221; crossorigin>
    <link rel=’dns-prefetch’ href=’//fonts.googleapis.com’ />
    <link rel=’stylesheet’ id=’poka-fonts-css’ href=’https://fonts.googleapis.com/css?family=Roboto%3A400%2C400italic%2C700%7C&display=swap&ver=4.0.4&#8242; type=’text/css’ media=’all’ />

    How can ew change this default behavior so that it’s being loaded from a local (first-party) resource and not from a remote resource?

    Thanks for your insights!

    #17852
    admin
    Keymaster

    Hi Jean-Sebastien,

    To do this, you first need to overwrite through the functions.php of your child theme the poka_dns_prefetch() function and you also have to use WordPress function wp_dequeue_style() to dequeue the “poka-fonts” stylesheet.

    Then you should add some CSS inside the style.css file inside your child theme to include the fonts you have locally.

    This requires a bit of CSS and PHP knowledge. Of course you can always send us an email at support@pokatheme.com for custom functionalities like this one.

    Thanks!

    #17865

    Hey, thanks for the guidelines!

    Problem with overwriting poka_dns_prefetch() function: in setup-theme.php, the function is defined without the usual if ( ! function_exists( ‘poka_dns_prefetch’ ) ) { on top of it,
    so I cannot redeclare the function in the child functions.php.

    Have I another choice but modifying the setup-theme.php and adding if ( ! function_exists( ‘poka_dns_prefetch’ ) ) { so I can redeclare the finctions in the child theme?

    thanks!

    #17868
    admin
    Keymaster

    Hi Jean-Sebastien,

    Unfortunately you are right, we missed to add the function_exists() check for this one, this will be fixed for sure in the next theme release.

    For now, you could use the following PHP snippet in your child theme functions.php to totally remove the stuff that the function poka_dns_prefetch() adds to the site.

    add_action(
    	'init',
    	function() {
    		remove_action( 'wp_head', 'poka_dns_prefetch', 1 );
    	}
    );
    

    Let me know if this works for you.

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