[Support request] GP and AMP

Home Forums Support [Support request] GP and AMP

Home Forums Support GP and AMP

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1290471
    Guillermo

    Hello good afternoon.
    Do you have any recommendation to implement AMP with GP?

    I am referring to a plugin that adapts to the functionalities implemented in GP.

    Thank you very much

    #1290569
    Leo
    Staff
    Customer Support

    Hi there,

    You would need this plugin:
    https://github.com/tomusborne/amp-for-generatepress

    Which works with the official AMP plugin only:
    https://en-ca.wordpress.org/plugins/amp/

    #1291037
    Guillermo

    Thank you very much Leo. Install both plugin and everything works OK.

    A question. How do I manage hooks to insert a different code in AMP and HTML pages?
    Especially by Adsense and analitycs.

    My English is not very good, I hope I was clear.
    Thanks a lot

    #1291054
    Guillermo

    I create a new hook, in php, and for the entire site.

    I put the following code:

    <?php
    if ( function_exists( ‘is_amp_endpoint’ ) && is_amp_endpoint() ) { ?>
    <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
    <?php } ?>

    But it doesn’t show me that script in HEAD

    I am doing something wrong?

    thanks a lot

    #1292322
    Tom
    Lead Developer
    Lead Developer

    Looks like you have some curly quotes in there.

    Try this:

    <?php
    if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { ?>
        <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
    <?php } ?>
    #1292357
    Guillermo

    Hello good afternoon.
    I put the code and it doesn’t work either.

    I put the following code to test if it enters through the ELSE, but neither does it.

    <?php
    if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { ?>
        <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
    <?php } else { ?>
    		<script custom-element="amp-ad"></script>
    <?php } ?>

    this line was temporary to test: <script custom-element=”amp-ad”></script>

    The configuration is:
    HOOK: wp_head
    Execute PHP: Checked

    Display rules: Entire Site

    I do not know what I’m doing wrong
    thanks for your help.

    #1292456
    Guillermo

    Hello, I kept testing alternatives and what I see is that the code works in an html post, but in AMP it does not work in any way (not even entering plain text)

    #1292867
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Any chance you can deactivate your caching plugin so I can take a look at the site source?

    #1292906
    Guillermo

    Hi.
    ready! cache is off. I hope it helps you.

    If you need, I can make you a copy of the wordpress so you can access and see all the settings and test.
    I had to pass you url, username and password privately.
    Thanks a lot

    #1294166
    Tom
    Lead Developer
    Lead Developer

    Something seems to be minifying the site HTML – Cloudflare maybe? Any chance you can turn that off as well?

    #1294180
    Guillermo

    hello,
    ready, minify html off
    can you check please?
    thanks

    #1294493
    Tom
    Lead Developer
    Lead Developer

    What happens when you add a manual hook?:

    add_action( 'wp_head', function() {
        if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { ?>
            <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
        <?php }
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

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