Insert ads into Infinite Scroll
-
I’ve been able to insert ads into my posts with Infinite Scroll enabled using this
<?php if ( have_posts() ) : ?> <?php $countpost = 0; ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * If you want to overload this in a child theme then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', get_post_format() ); ?> <?php// echo $countpost ?> <?php if ( ($countpost == 3) ) : ?> <?php { wp_template_ad("2"); ?> <?php $countpost = 0; } ?> <?php endif; $countpost++; ?> <?php endwhile; ?>in my “the loop” logic in both index.php and archive.php, the only looping that I can find in my theme files.
The problem is that it works for the initial page load, but apparently uses some other “the loop” to append the additional posts during infinite scrolling. Thus, only a couple of ads show up in the posts listed.
Can anyone help me out with this?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Insert ads into Infinite Scroll’ is closed to new replies.