How to Add / Show Google Adsense Ads in AMP WordPress

Google adsense solution in amp wordpressThere is no need to tell you why Adsense in important to our site. Hope you already configure your site AMP comfortable. As you know previously we discussed Adding menu, Related post, Analytic code in AMP Posts. We also solve Popular problem “A value for the image field is required” Also solved by us. Today we discuss Google Adsense implementation in AMP WordPress site. Many of us always confuse that Is AMP support Google Adsense or not. There is good news AMP [Accelerated Mobile Pages] full comfortable with Google Ads.

Why Google Ads not Showing in AMP WordPress :

You already know AMP have an own structure of every action. Its not basic HTML. Same things apply on Google Ads. Google Adsense ordinary format did not work in  AMP. There is a special format for AMP Google Ads.
Google Ordinary Ad Format:
<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<ins class=”adsbygoogle”
style=”display:inline-block;width:336px;height:280px”
data-ad-client=”ca-pub-95675557XXXXXXXX”
data-ad-slot=”170XXXXXXX”></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Google AMP Format :
<amp-ad width=350 height=100
type=”adsense”
data-ad-client=”ca-pub-95675557XXXXXXXX”
data-ad-slot=”170XXXXXXX”>
</amp-ad>

Here you see there is big different in the code. So if you try with ordinary code in AMP plugin editor then its sure Ads not appear in AMP Page.

How to Show Google Adsense Ads in WordPress AMP Post :

As you know there is less support available for AMP. however, we edit the code and implement Google Adsense on Posts. Hope you like it. Follow below steps to Add Adsense ad in your AMP site.

  1. Open Plugin Editor (Not Theme Editor).
  2. Choose AMP plugin and Press Select Button.
  3. Open amp/templates/single.php file.
  4. Find <div class=”amp-wp-content”> line. And below the line  paste our AMP Comfortable Ad code (Which described above paragraph).
  5. Find do_action( ‘amp_post_template_footer’, $this ); before the php starting tag paste Google AMP Ad code.
  6. Save the file. All Set.

Congratulation You successfully add google Ads in your AMP WordPress site. We understand you don’t like code editing. but be patient we are coming with a plugin solution soon. Have a good day.

3 comments

  1. i noticed that you placed center of post in AMP Page,

    Please share with me, How i can do.

    i Placed at top and Bottom of post.

    1. Hi Jaysukh,
      Thanks for writing here. We are happy to know that you successfully implemented AMP on your Site. Soon we post a detailed guide for placing google ads in the middle of the Post.
      Stay tuned.
      Kind Regards

Leave a Reply

Your email address will not be published. Required fields are marked *