I added infinite scroll support of the Jetpack plugin to my own theme using this tutorial:
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => false,
'render' => 'vividflow_infscroll_render',
'wrapper' => 'post_summaries',
'posts_per_page' => 12,
'type' => 'scroll'
) );
Now I need something like a counter which increments every time additional posts are loaded.
I know that the new posts are placed in an infinite-view-
n
class and I have a JavaScript function which I want to call on that new loaded class:
function setupPostSummaries(counter) {
jQuery('.infinite-view-'+counter).doSomething();
}
So I guess I need a PHP variable in the infinite scroll render function or the loop which increments every time additional posts are loaded. Then I can do in the end of The Loop:
<script type="text/javascript">setupPostSummaries(<?php the_counter(); ?>);</script>
Is such a variable there already? Or is there an other way to achieve my goal?
numberposts
is deprecated. Added a replacement.