How to Insert Adsense Ads in The Middle of AMP Post?

0
2211
Insert Adsense Ads in The Middle of AMP Post

For those of you who are implementing Google AMP (Accelerated Mobile Page) on the website/blog will certainly face some problems, because the Google AMP is relatively new, so there are many people who are not familiar with this AMP. Besides that, not all the features/scripts from your standards website/blog can be migrated or can be obtained on AMP page. One of them is the issue of Google Adsense implementation on AMP page, especially the implementation of Adsense Ads in the middle of articles/posts. So, How to Insert Adsense Ads in The Middle of AMP Post of Your WordPress?

Actually, some supporting AMP plugins for wordpress have been providing some features like custom design, adding google analytics to AMP posts or pages, the addition of featured image, adding related articles/posts, add sharing to social media, even plugins to support inserting adsense ads was actually already exist, but they are limited to adsense placement on the top and bottom of the page. There is not yet free plugin to insert Adsense ads in the middle of posts/articles. So how do I insert Adsense ads in the middle of AMP posts?

Fortunately I have found an article that explains how to insert Adsense Ads in the middle of AMP post here (thanks Isabel). That article has explained about how to insert Adsense Ads code in articles after a few paragraphs, how to insert Adsense Ads within the content after a certain number of paragraphs, and also explain on how to creates one shortcode that works on both regular and AMP (Accelerated Mobile Pages) to display your Google Adsense ads.

Nevertheless, the guidelines still did not fit my needs. Although the article has given functions and some codes to insert Adsense Ads in the middle of AMP post, I still find it difficult to implement that on website’s theme that I am using. Finally, I tried to combine that codes with a plugin to insert ads on a post after the specify paragraph(s). That plugin is LH Multisite Ads, which you can download here

Steps to Insert Adsense Ads in The Middle of AMP Post

Here are the ways that I have done to combine the code to insert Adsense Ads in the middle of AMP post (insert Adsense Ads within the content after a certain number of paragraphs) with the LH Multisite Ads plugin (Adsense Ads code inserted for the AMP post with this plugin will not be recognized by the regular post)

  1. Create a responsive Ad unit (or 300 x 250) and make note of the Ads ID
  2. Install and activate LH Multisite Ads plugin
  3. Create a Post Adverts, give a name and paste your AMP ad code in the post adverts box. After that hit Publish button.

    replace line 6 and 7 with your Google Adsense Ad client and Ad slot code
  4. Open and edit your LH Multisite Ads plugin (lh-multisite-ads.php). Locate function : insert_ads and replace that function with this code (copy and paste line 1 to 26) or just add line 3 and 24 into original insert_ads function of this plugin (lh-multisite-ads.php)

With these steps, now I have been able to meet the needs of my blog and have been able to get a solution to the question of how to insert Adsense ads in the middle of post after certain paragraphs. Hopefully this post will be useful for you in resolving similar issues