xfpoint

How to Show Ads Only In The First Post Of XenForo 2

Adding advertisements in XenForo 2 is a cakewalk. XenForo 2 has many ad locations within the layout and well organized in the admincp. Visit XenForo admincp > Setup > Advertising and click the Add advertisement button in the top right corner.

Choose a Title for the ad, it is only for reference in the admin area and not visible to the user. Select Post: Above message content or Post: Below message content as position, and in the HTML box add your ad code.

The ad code will repeat in each post for post_above_content and post_below_content and one needs to add the following conditional in the HTML to restrict the ads to be shown only in the first post

<xf:if is="$post->position == 0">
YOUR AD CODE HERE
</xf:if>

If you wish to show ads in the second post change the position conditional to 1.

<xf:if is="$post->position == 1">
YOUR AD CODE HERE
</xf:if>

Exit mobile version