The $wp_query->current_post inside the wordpress will help you to fix this issues. It will get the count of the current loop executed in the wordpress. And if the loop (post) is the 4th one , we can block the script from being run.
< ?php if (have_posts()) : ?> < ?php while (have_posts()) : the_post(); ?> < ?php if($wp_query->current_post < 3) : ?>Advertisements< ?php endif; ?> < ?php endwhile; ?> < ?php endif; ?>
Remember that the wordpress loop count start with zero, you can limit the number of ad units displayed to 1 or 2 by changing the $wp_query->current_post < 3 as per you wish