Title: header footer code
Last modified: December 8, 2023

---

# header footer code

 *  Resolved [Nitin Jain](https://wordpress.org/support/users/glamsham/)
 * (@glamsham)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/header-footer-code/)
 * Hi,
 * I have been struggling to find how / where to add / insert the google adsense
   auto ads header footer codes. I couldn’t find a place in the AMP plugin. Kindly
   guide.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/header-footer-code/#post-17270838)
 * Hello [@glamsham](https://wordpress.org/support/users/glamsham/)
 * Thank you for contacting us, As you mentioned in the previous support topic you
   are using the Newspaper theme by tagDiv, You can try adding auto-ads code in 
   header using `wp_head` hook.
 * eg:
 *     ```
       add_action( 'wp_head', function() {
               ?>
       <amp-auto-ads type="adsense" data-ad-client="ca-pub-xxxxxxxxxxxxxxx">
       </amp-auto-ads>        
       <?php
       } );
       ```
   
 * You also use the [Sitekit by Google](https://wordpress.org/plugins/google-site-kit/)
   plugin which integrates all goole services including auto ads in your AMP and
   non-AMP pages.
 * You can also try using this [mini-plugin](https://gist.github.com/westonruter/a41573b932e24810b09949136b9a8445)(
   to install follow the instructions in the comments)
 * We hope this helps!
 *  Thread Starter [Nitin Jain](https://wordpress.org/support/users/glamsham/)
 * (@glamsham)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/header-footer-code/#post-17274305)
 * Hi,
 * This is confusing me as the [link](https://amp.dev/documentation/components/amp-auto-ads)
   indicates that the code is to be implemented in the body!
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/header-footer-code/#post-17276752)
 * Hello [@glamsham](https://wordpress.org/support/users/glamsham/)
 * Sorry about confusion, Please try using it on `wp_body_open` or `amp_post_template_body_open`
   and see if that works for you
 *     ```
       add_action( 'wp_body_open', function() {
               ?>
       <amp-auto-ads type="adsense" data-ad-client="ca-pub-xxxxxxxxxxxxxxx">
       </amp-auto-ads>        
       <?php
       } );
       ```
   
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/header-footer-code/#post-17321250)
 * [@glamsham](https://wordpress.org/support/users/glamsham/) As we didn’t receive
   a response I’ll mark this as resolved. Feel free to open a [new support topic](https://wordpress.org/support/plugin/amp/#new-post)
   if you require any further assistance.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘header footer code’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

## Tags

 * [Auto Ads](https://wordpress.org/support/topic-tag/auto-ads/)

 * 4 replies
 * 2 participants
 * Last reply from: [Milind More](https://wordpress.org/support/users/milindmore22/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/header-footer-code/#post-17321250)
 * Status: resolved