1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 Adsense and template ad_message_below how to force to appear only on first post

Discussion in 'Troubleshooting and Problems' started by kaloksi, Aug 21, 2014.

  1. kaloksi

    kaloksi Member

    Hi,

    Can you tell me suggestions to make template ad_message_below to work so that it only posts once an adsense banner?

    If I add code as adsense provides and I have 6 posts in a thread it will display banner 6 times and google does not like this at all.

    So how can I force ad_message_bellow to be displayed only on a single post?

    Thanks in advance.
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    brattanek likes this.
  3. kaloksi

    kaloksi Member

    Many thanks, much appreciated.

    Here the code I have added

    Code:
    <xen:hook name="ad_message_below" />
    
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="XXXXXXXXX"
         data-ad-slot="YYYYYYYY"
         data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
      
    </xen:if>
    with XXXXXX and YYYYYYY the code bits that depend on each adsense setting. I have used google's new responsive ads.
     

Share This Page