Insert image or ad script after 3 posts using the loop

instead of a post counter, you could use the variable $wp_query->current_post – which starts with 0 for the first post in the loop;

for some output after the third post, use for instance this before the line with endwhile;:

<?php if( $wp_query->current_post == 2 ) { ?>
DO SOMETHING
<?php } ?>

Leave a Comment