- This topic has 12 replies, 4 voices, and was last updated 3 years, 5 months ago by Tom.
-
AuthorPosts
-
October 18, 2020 at 11:30 am #1494626Patrick
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 #1494634LeoStaffCustomer 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 π
October 18, 2020 at 11:42 am #1494637PatrickYes, it is installed and activated.
October 18, 2020 at 12:30 pm #1494710TomLead DeveloperLead DeveloperHi there,
I’m seeing ads on that page: https://www.screencast.com/t/L6cYBY46P
October 18, 2020 at 12:32 pm #1494712PatrickI 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 #1494780ElvinStaffCustomer 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.
October 19, 2020 at 8:58 am #1495793PatrickStill 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 #1496150TomLead 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.
October 19, 2020 at 1:13 pm #1496160PatrickHook 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 #1497359TomLead 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?
October 20, 2020 at 9:57 am #1497385PatrickYes, the plugins are working.
October 20, 2020 at 10:11 am #1497405PatrickUsing 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 #1497644TomLead 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.
-
AuthorPosts
- You must be logged in to reply to this topic.