Place ad after last post


Active member
If this has been solved before, then I apologize, but I searched and searched and did not find a great answer to this problem.

I needed to be able to show an ad after the last post on each page. All the solutions I found would not work if the page did not fill all the slots for a full page. This does:

<xen:if is="{$message.position} == {$xenOptions.messagesPerPage} - 1 OR {$message.position} == {$thread.reply_count}">
   <!--AD CODE HERE -->
I just wanted to post this here so others and myself can find it again in the future when needed.


Well-known member
So is there a way to do with via conditionals? I am looking to place an ad in the last post of each page (granted it's not the first or second post)


Active member
Is there a way with the conditionals to do a placement "if there are 3 or more posts, then place in the last post?"

edit: edit: nope, my edit was wrong. I still have this question, and settling for a third post placement in the meantime.
Last edited:


Active member
I'm trying to piece some of the previous discussions together into a working answer.

What's the right way to write this?

<xen:if is="{$post.position} == {$thread.reply_count} AND {$xenOptions.messagesPerPage} > 2">

I'm looking for the last post on a page only if there are more than 2 posts on that page.


Active member
$5 paypal to the working answer just to make my day more excellent.

Using Xenforo conditionals and not a paid add-on, I want to place an ad in the last post of every page only if there are 3 or more posts on the page being viewed.

If there are 7 posts it goes in post 7, if there are 3 posts it goes in post 3. If it's the first post on the second page, it should not display.


XenForo moderator
Staff member
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$thread.reply_count} AND {$thread.reply_count} % {$xenOptions.messagesPerPage} > 1">
    Ad code here