• Hi,

    I use this code to display AdSense on single pages and AMP.

    I’m seeing this error in the AMP Test: Tag <Script> is not allowed

    Can anyone help me to fix this code?

    Thanks!!

    add_filter( 'the_content', 'prefix_insert_post_ads' );
    function prefix_insert_post_ads( $content ) {
      $ad_code = '<div class="insertads">
    <!-- Naijforum Rectangle ads  -->
    <amp-ad data-ad-client="ca-pub" data-ad-slot="828" height="250" layout="responsive" type="adsense" width="300">
     </amp-ad>
    <ins class="adsbygoogle"
         style="display:block; text-align:center;"
         data-ad-format="fluid"
         data-ad-layout="in-article"
         data-ad-client="ca-pub"
         data-ad-slot="828"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </div><br>';
      if ( is_single() && ! is_admin() ) {
                return prefix_insert_after_paragraph( $ad_code, 2, $content );
      }
      return $content;
    }
    • This topic was modified 7 years, 7 months ago by renefraga.
  • The topic ‘AMP Error –’ is closed to new replies.