- This topic has 12 replies, 4 voices, and was last updated 2 years, 5 months ago by
Tom.
-
AuthorPosts
-
October 18, 2020 at 11:30 am #1494626
Patrick
I’ve added this code to Hook wp-head:
<script data-ad-client="ca-pub-XXXXXXXXXX" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"></script>
… and, I’ve added this code to Hook wp-body-open:
<amp-auto-ads type="adsense" data-ad-client="ca-pub-XXXXXXXXXX"> </amp-auto-ads>
However, I still get no ads for the amp version of pages.
Here is an example:
Any suggestions? Thanks π
October 18, 2020 at 11:41 am #1494634Leo
StaffCustomer SupportHi there,
Can you first confirm that you are using the AMP for GP plugin?
https://github.com/tomusborne/amp-for-generatepressIt should work with the official AMP plugin:
https://en-ca.wordpress.org/plugins/amp/Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 18, 2020 at 11:42 am #1494637Patrick
Yes, it is installed and activated.
October 18, 2020 at 12:30 pm #1494710Tom
Lead DeveloperLead DeveloperHi there,
I’m seeing ads on that page: https://www.screencast.com/t/L6cYBY46P
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 18, 2020 at 12:32 pm #1494712Patrick
I just now placed a manual ad below the header but am still not getting any auto ads. Are you seeing just the one below the header or more than one ad per page? Thanks π
October 18, 2020 at 2:37 pm #1494780Elvin
StaffCustomer SupportHi,
Are you seeing just the one below the header or more than one ad per page?
I’m only seeing this. https://share.getcloudapp.com/E0urjWKA
Yes. Just the one below the header.
A wise man once said:
"Have you cleared your cache?"October 19, 2020 at 8:58 am #1495793Patrick
Still not resolved. It appears other plugin users are having similar issues. Should I try a different hook location?
October 19, 2020 at 1:07 pm #1496150Tom
Lead DeveloperLead DeveloperWhat hook location are you using?
The theme itself doesn’t control this – once the necessary scripts are added in the correct location, it’s 100% up to the ad provider to place them.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 19, 2020 at 1:13 pm #1496160Patrick
Hook wp-head and Hook wp-body-open for the auto ads. (not working)
Hook wp-head and Hook generate_after_header for the manual ad. (working)
Since the manual is working and auto is not, it leads me to believe that there is something wrong with the placement of the wp-body-open for the auto ads. A few other users had the same issue in the forums, but I don’t want to use another plugin to make it work if I don’t have to.
October 20, 2020 at 9:37 am #1497359Tom
Lead DeveloperLead Developerwp_body_open
should be placed directly inside the<body>
element, which it is here: https://github.com/tomusborne/generatepress/blob/3.0.2/header.php#L27Do any of the plugins work?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 20, 2020 at 9:57 am #1497385Patrick
Yes, the plugins are working.
October 20, 2020 at 10:11 am #1497405Patrick
Using Ad Inserter, everything works fine. However, I should not have to use the additional plugin … the issue is with GeneratePress or the GP Premium plugin. Others have had the exact same issue, not just me.
See here:
October 20, 2020 at 1:57 pm #1497644Tom
Lead DeveloperLead DeveloperHave you tried what was mentioned here?: https://generatepress.com/forums/topic/add-adsense-auto-ad-code-for-amp-pages/#post-1386008
I’m not sure how the theme could be interfering with the code – it’s just HTML being added to the page. You can bypass the theme completely with some functions if you’d like:
add_action( 'wp_head', function() { ?> <script data-ad-client="ca-pub-XXXXXXXXXX" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"></script> <?php } ); add_action( 'wp_body_open', function() { ?> <amp-auto-ads type="adsense" data-ad-client="ca-pub-XXXXXXXXXX"> </amp-auto-ads> <?php } );
That takes the theme completely out of the equation.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.