- This topic has 11 replies, 3 voices, and was last updated 3 years, 11 months ago by Tom.
-
AuthorPosts
-
May 18, 2020 at 9:42 am #1290471Guillermo
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
May 18, 2020 at 10:36 am #1290569LeoStaffCustomer SupportHi there,
You would need this plugin:
https://github.com/tomusborne/amp-for-generatepressWhich works with the official AMP plugin only:
https://en-ca.wordpress.org/plugins/amp/May 18, 2020 at 6:49 pm #1291037GuillermoThank 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 lotMay 18, 2020 at 7:19 pm #1291054GuillermoI 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
May 19, 2020 at 9:34 am #1292322TomLead DeveloperLead DeveloperLooks 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 } ?>
May 19, 2020 at 9:52 am #1292357GuillermoHello 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: CheckedDisplay rules: Entire Site
I do not know what I’m doing wrong
thanks for your help.May 19, 2020 at 10:58 am #1292456GuillermoHello, 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)
May 19, 2020 at 4:31 pm #1292867TomLead DeveloperLead DeveloperHi there,
Any chance you can deactivate your caching plugin so I can take a look at the site source?
May 19, 2020 at 4:56 pm #1292906GuillermoHi.
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 lotMay 20, 2020 at 9:54 am #1294166TomLead DeveloperLead DeveloperSomething seems to be minifying the site HTML – Cloudflare maybe? Any chance you can turn that off as well?
May 20, 2020 at 10:03 am #1294180Guillermohello,
ready, minify html off
can you check please?
thanksMay 20, 2020 at 2:32 pm #1294493TomLead DeveloperLead DeveloperWhat 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/
-
AuthorPosts
- You must be logged in to reply to this topic.