How to display Google Adsense ads automatically in amp pages?

Recently Google Adsense has launched an option to display ads automatically in amp pages. You can display Adsense auto ads in WordPress by adding two codes directly in Amp plugin by Automattic, but also in static html pages.

Displaying Adsense ads automatically in amp pages is a good opportunity because it simplifies things. You do not have to worry about the position and number of ads to be displayed. This is best done with two codes provided by Google Adsense.

Where to get the codes that show ads automatically in amp pages?

  1. Open your Google Adsense account.
  2. Click Optimizations, then click Labs.
  3. On the right side, click the button to enable amp auto ads, then click Get Code.
  4. Copy two codes then paste in your html, template page.
  5. Paste first code between <head>…</head> tags, then paste second code below <body> tag. (See the image above in this article)

 

Where to paste Amp auto ad codes in WordPress ?

An example with currently installed Amp plugin by Automattic (WordPress.com VIP, XWP, Google, and contributors)

  1. Open WordPress Dashboard.
  2. Go to Plugins, click Editor, then select Amp plugin.
  3. Under Plugin Files click html-start.php.
  4. Under <head> tag paste first code.
  5. After <body> tag paste second code. (See the image below in this article)

Paste Amp auto ads in WordPress

 

To set these codes there are also other methods. If you use this method, you should know something. If the Plugin is automatically updated, the custom codes can be deleted. That’s why you need to disable automatic updating of this Plugin.

Deactivate automatic update of plugins.

  1. Go to Appearance, click Editor. You should still have a child theme, otherwise this action has no effect.
  2. Under Theme Files open Theme Functions (functions.php).
  3. Paste this code: add_filter( ‘auto_update_plugin’, ‘__return_false’ );

Setting this code deactivates automatic update for all plugins. If you could find a method to save codes without deactivating automatic update, it would be a lot better. This because update is very important for all apps.

 

Add a Comment

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