3 Ways to Add Google Adsense Ads to Your WordPress AMP Pages

The AMP Project (Accelerated Mobile Pages) by Google has picked up steam and you should get into the bandwagon. Otherwise, there is a chance that you will miss out on heavy organic search traffic allocated for AMP based pages. If you own a WordPress site then it is easy to implement AMP versions of your posts using the official AMP plugin by WordPress. The plugin is called AMP, by Automatic

Since AMP is still new to many novice webmasters, customizing the output of the pages has become a great challenge. The aforementioned AMP plugin will create very basic AMP versions of your site which does not even include a menu bar or placement for Google Adsense Ads. As a webmaster, you definitely don’t want to miss out on ad revenue from Adsense from your AMP pages. So, here are 3 ways to insert Adsense code to your WordPress AMP pages. Before you get started, note that the Adsense code for AMP pages is stripped down to bare minimum. Consult this guide to have your Adsense code ready. 

Method 1: Manually Inserting the Ad Code Using the AMP Plugin Editor

If you have the official AMP plugin installed, you can add the Adsense code in the plugin manually. Make sure that you are comfortable with editing codes, otherwise try Method 2 or 3. The following method will place ads below the article or below the fold. Here are the steps:

Step 1: Open the Plugin Editor from the WordPress menu bar. 

plugin editor

Step 2: Select “AMP” from the Select Plugin to Edit drop down list and press Select.

amp plugin edit

Step 3: From the Plugin Files area, expand templates and click on single.php

amp single.php

Step 4: Once you have the code for single.php visible, insert the code listed under Step 4 of this guide between the < head > and < /head > tags of your AMP html code.

Step 5: Locate < div class = ” amp-wp-article-content ” > line. Usually line # 26. Then, just above the closing div, < / div >, paste your ad code which you prepared prior to executing method #1. 

amp article div

Step 6: Save the changes by clicking on the Update File button.

Method 2: Inserting the Ad Code Using Functions

This page lists several ways of adding Adsense ad code to your WordPress site. The guide allows flexibility in placing ads in various places, including Before Content, After Content, after certain number of paragraphs, etc. 

The guide deals with updating the Functions file of your theme. Any update you make to the functions usually get overwritten during a theme update. As a result, it is strongly advised that you use a plugin like My Custom Functions before using the guide.

Method 3: Inserting Ad Code Using a Plugin

The Ad Inserter Plugin for WordPress has a useful feature to insert ads in AMP pages. After installing the plugin, go to the Settings Page for Ad Inserter. Paste the ad code in a Block and click on the Misc button.

ad inserter misc

Under Insertion tab, click on AMP Pages. This will place the ad code in your AMP pages.

ad code on amp pages

Thanks for reading.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Scroll to Top