• Resolved Steve D

    (@steadwell)


    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?

    http://wordpress.org/plugins/jetpack/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    I would recommend that you check this tutorial to find out how your theme is built and where the loops used by Infinite Scroll are located.

    Let me know if it helps.

    Thread Starter Steve D

    (@steadwell)

    Thanks for the quick response Jeremy!

    It appears that Jetpack IS processes the additional posts with it’s own queries after the standard modules have completed their reads. I’m still looking into more approaches either in stead or in addition to what I’ve got in place.

    The suggested reading is somewhat helpful, though I’d read it previously but there is apparently something I’m missing as to how it relates to my Book Lite child theme.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    What happens if you use get_template_part to add your ad template to content.php, and check the post count there?

    Thread Starter Steve D

    (@steadwell)

    I think I’ll just put one ad in a floating div that will be independent of the posts list. That would likely be the best approach since I don’t want to inundate the viewer with too many ads.

    Thanks for your help!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Insert ads into Infinite Scroll’ is closed to new replies.