Jetpack Infinite Scroll – Insert ad code every 6th post?
-
I’ve been able to get this to work on the first loop of 6 posts, but subsequent blocks of posts that come in via infinite scroll do not have the ad in place.
I’ve been using the following:
Before Loop:
<?php $countpost = 0; ?>
With this added into the content loop:
<?php if ( (is_archive() or is_page() or is_search() or is_home()) && ($countpost == 6) ) : ?> AD CODE HERE <?php endif; $countpost++; ?>
My content loop (without the code above) is:
<div id="content"> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; // end of the loop. ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Jetpack Infinite Scroll – Insert ad code every 6th post?’ is closed to new replies.