Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to add a script or ads after 1st post of every topics


chrishajer
Participant

@chrishajer

Just add it to the template file. To make it show up after the first post only, you need a counter to see which post you’re looping through. I did something like this:

<ol id="thread" class="list:post">

<?php foreach ($posts as $bb_post) : $del_class = post_del_class(); ?>
<li id="post-<?php post_id(); ?>"<?php alt_class('post', $del_class); ?>>
<?php bb_post_template(); ?>
</li>
<?php if ($adcounter == 0) {
$adcounter++;
// <div id="adcode">paste ad code here</div>
} ?>
<?php endforeach; ?>

</ol>

Basically just add the adcounter check and ad code right after the closing <li> right after the post_template. You’ll have to adjust the particulars for your installation, but this is the basic process.

Skip to toolbar