WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have one loop on my homepage that I use infinite scroll to paginate. To keep the load time of the homepage down, I want to load a smaller initial amount than when the infinite scroll is triggered for the first time. So on page load I want 10 posts loaded and then every trigger after that I want the post_per_page to equal 25. Is that possible? Im using Infinite Scroll Jquery plugin. Not the wordpress version. I use this script after the loop to trigger the infinite scroll.

<div class="infinitescroll">
<?php next_posts_link( __( 'Load more posts', 'imbalance2' ) ); ?>

<script type="text/javascript">
 // Infinite Scroll
 var href = 'first';
 $(document).ready(function() {
    navSelector : '.infinitescroll',
    nextSelector : '.infinitescroll a',
    itemSelector : '#boxes .box',
    loadingImg : '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',
    loadingText : 'Loading...',
    donetext : 'No more pages to load.',
    debug : false
}, function(arrayOfNewElems) {
    $('#boxes').masonry('appended', $(arrayOfNewElems));
    if (href != $('.infinitescroll a').attr('href'))
        href = $('.infinitescroll a').attr('href');
share|improve this question
Do you use a plugin for the infinitescroll function? – janw May 8 '12 at 9:54
Im using Infinite Scroll Jquery plugin. Not the wordpress version. – Pollux Khafra May 8 '12 at 10:04
up vote 0 down vote accepted
  1. Add a parameter to the href URI for the next posts link per JavaScript. For example ?ppp=25.
  2. Add a filter to pre_get_posts, check if ppp is set (and a positive integer) and change the post_per_page parameter accordingly.

Just an idea, no code, but it should give you a direction. :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.