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

XF 1.3 Place an ad after every 5th post

Discussion in 'Styling and Customization Questions' started by caliman, Jun 25, 2014.

  1. caliman

    caliman Active Member

    I posted this in the conditional thread and was told to use xen:calc. Unfortunately there are not a lot of examples of this.

    So.. I was curious if anyone knows how to place an ad after every 5th post on a page?

    Thanks in advance!

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> post

    Add this code to the top of this template:

    <xen:if is="{$post.position} % 5 == 1">
    That will hit after every 5 posts, starting with the first post.
    caliman and MichaelDance like this.
  3. caliman

    caliman Active Member

    A big thank you to you Jake. That is in the ballpark... it puts it in after 1st post, 6 post, 11 post, 16 post etc.. That will work just fine.
    Oddly, my banner server is displaying the same banner in all those spots. That may be something outside of xF though. Thanks again
  4. Mr Lucky

    Mr Lucky Well-Known Member

    Are you using Adsense? I think there is a limit of 3 ads per page.
  5. caliman

    caliman Active Member

    No it's my own ads. Fairly odd as it is just an html image tag and hyperlink. I suspect caching as I have a lot of that going on.
  6. caliman

    caliman Active Member

    I figured out my caching issue - that is, I have a solution that works - I simply added a dummy variable to the end of the HREF and IMG tag that have the post position number - that way - each banner has different code - does not get cached - and loads.


Share This Page