How best to inject ads between posts in the loop?

Probably just add a counter, show ad on multiples of 6.

Something like

$count = 0;
$adEvery = 6;

if (have_posts()) :
    while (have_posts()) : the_post();

        // Individual Post

        $count++;
        if ($count%$adEvery == 0) { 
            // your ad
        } 
    endwhile;
else :
    // No Posts Found
endif;

Leave a Comment