• Hello,

    I’ve succesfully installed & setup AMP plugin on my site. Could you guys help me out how to use Google Fonts? I tried to set it up through CSS but it doesn’t work. I have no idea where to start.

Viewing 1 replies (of 1 total)
  • Hi @kherlen

    If you want to, like me, use your own Google Fonts and remove the default one (Merriweather), you will have to do 2 steps:

    1 – Remove the default Merriweather:
    Fot that you will have to hack a core file oh this plugin ( /amp/class-amp-post-template.php ). Edit this file and just comment the line below, like this:

    /*
    'font_urls' => array(
    'merriweather' => 'https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic',),
    */

    2- Add you own Google fonts: add the snippet below into you wordpress theme functions.php (assuming you are using a child theme…):

    add_action( 'amp_post_template_head', 'xyz_amp_add_head' );
    function xyz_amp_add_head( $amp_template ) {
        ?>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Quicksand">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:300">
        <?php
    }

    > Of course the Google Fonts in this exemple are mine, but feel free to add you own…

    It Works, and my Amp posts are validated: https://www.domodeco.fr/reportages/visite-privee/maison-a-couper-souffle-dune-pilat.html/amp

    Please note that I’m not using anything else that just the AMP Plugin (no Yoast glue, etc.)

    PS: in a near future it seems that it will be possible to do it more easily :
    https://github.com/Automattic/amp-wp/commit/c60894b6d68055e88210e41d5be6fa7550a5f5db

    • This reply was modified 9 years, 8 months ago by pako69.
    • This reply was modified 9 years, 8 months ago by pako69.
Viewing 1 replies (of 1 total)

The topic ‘How to setup Google Fonts’ is closed to new replies.