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?
- Open your Google Adsense account.
- Click Optimizations, then click Labs.
- On the right side, click the button to enable amp auto ads, then click Get Code.
- Copy two codes then paste in your html, template page.
- 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)
- Open WordPress Dashboard.
- Go to Plugins, click Editor, then select Amp plugin.
- Under Plugin Files click html-start.php.
- Under <head> tag paste first code.
- After <body> tag paste second code. (See the image below in this article)
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.
- Go to Appearance, click Editor. You should still have a child theme, otherwise this action has no effect.
- Under Theme Files open Theme Functions (functions.php).
- 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.