Site logo

Archived topic

GP and AMP

11 replies · Started by Guillermo on May 18, 2020

Viewing posts 1–12 of 12

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

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

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

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 } ?>

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.

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)

Hi there,

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

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

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

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

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/

This archived topic is closed to new replies.