Title: Custom Code in AMP
Last modified: October 14, 2019

---

# Custom Code in AMP

 *  [shreen2008](https://wordpress.org/support/users/shreen2008/)
 * (@shreen2008)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/custom-code-in-amp/)
 * Hello.
 * I am trying to place “custom ad script” code inside the content of AMP pages.
 * This is the code.
 *     ```
       <amp-iframe
             src="https://embed.empower.net/?video=5855011e-efd8-46ab-b2f6-d6191f1ac299&player=8261f255-3039-456d-a2b4-7c8e68bb3fb7&site=30a9d67f-911c-406c-89d3-ba68ed6d7dd9&siteName=windowstechit"
             sandbox="allow-scripts allow-same-origin"
             frameborder="0"
        layout="responsive"
             height="360"
             width="640">
             <amp-img layout="fill" src="https://str.empower.net/thumbnails/5855011e-efd8-46ab-b2f6-d6191f1ac299.jpg" placeholder></amp-img>
       </amp-iframe>
       ```
   
 * But it is not working or displaying.
    Adsense Ads are working as intended.
 * But if I place any custom code, it is not working .
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcustom-code-in-amp%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Davide Prevosto](https://wordpress.org/support/users/daweb/)
 * (@daweb)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/custom-code-in-amp/#post-12032211)
 * Hello [@shreen2008](https://wordpress.org/support/users/shreen2008/),
 * I think you’ll be able to solve your issue in this way:
 * 1) open the file ./output/functions.php
    2) find `' . strip_tags( $custom_ad_code,'
   <amp-ad><amp-embed>' ) . '`, ~807 row (not sure about right row number) 3) replace
   with `' . strip_tags( $custom_ad_code, '<amp-ad><amp-embed><amp-iframe>' ) . '`
 * I hope it will help.
 * Kind regards
    -  This reply was modified 6 years, 7 months ago by [Davide Prevosto](https://wordpress.org/support/users/daweb/).
 *  Thread Starter [shreen2008](https://wordpress.org/support/users/shreen2008/)
 * (@shreen2008)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/custom-code-in-amp/#post-12037368)
 * [@daweb](https://wordpress.org/support/users/daweb/) : Thanks it worked. Nice
   tip.
 * I also have another problem with custom Adsense code.
    I am trying to put this
   code as custom code.
 *     ```
       <div>
       <!-- Microsoft_ATF_336x280 -->
       <ins class="adsbygoogle"
            style="display:inline-block;width:336px;height:280px"
            data-ad-client="ca-pub-6837307237823202"
            data-ad-slot="1849388891"></ins>
       <script>
       (adsbygoogle = window.adsbygoogle || []).push({});
       </script><br/>
       <!-- Responsive_MTF_LinkAds_Windows -->
       <ins class="adsbygoogle"
            style="display:block"
            data-ad-client="ca-pub-6837307237823202"
            data-ad-slot="6566725542"
            data-ad-format="link"
            data-full-width-responsive="true"></ins>
       <script>
       (adsbygoogle = window.adsbygoogle || []).push({});
       </script>
       </div>
       ```
   
 * But only the first Adsense Ad is displayed. The second one is not displaying.
   
   I want it to work for only non-AMP pages only. I think that option is there in
   the plugin. But my problem is both ads are not displaying.
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/custom-code-in-amp/#post-12047067)
 * I’m sorry, The custom code section has been a problem lately for you, I have 
   created a ticket for this: [https://github.com/ahmedkaludi/ads-for-wp/issues/278](https://github.com/ahmedkaludi/ads-for-wp/issues/278)
 * We will fix this up in the next update
 *  Thread Starter [shreen2008](https://wordpress.org/support/users/shreen2008/)
 * (@shreen2008)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/custom-code-in-amp/#post-12067123)
 * Hello.
    There have been a few updates to your plugin. Every update is over-writing
   my ./output/functions.php changes. You said you will fix it in next update. It
   is still not fixed and the above solution is being rewritten everytime you make
   a update.
 * How to solve this.
 *  [santosh8793](https://wordpress.org/support/users/santosh8793/)
 * (@santosh8793)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/custom-code-in-amp/#post-12122591)
 * Hi shreen2008,
 * We have fixed the custom code issue in our last update, please check it once 
   and let us know if you have any issue.

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

The topic ‘Custom Code in AMP’ is closed to new replies.

 * ![](https://ps.w.org/ads-for-wp/assets/icon-256x256.png?rev=1919470)
 * [Easy Google Adsense and Banner Ads Manager - AdsforWP](https://wordpress.org/plugins/ads-for-wp/)
 * [Support Threads](https://wordpress.org/support/plugin/ads-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/ads-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ads-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ads-for-wp/reviews/)

## Tags

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

 * 5 replies
 * 4 participants
 * Last reply from: [santosh8793](https://wordpress.org/support/users/santosh8793/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/custom-code-in-amp/#post-12122591)
 * Status: not resolved