• Hi, I just did an infinite scroll to my test page, but it sometimes can load more, but sometimes just stucks. please help.

    <script type=”text/javascript”>
    var count = 2;
    var total = <?php echo $wp_query->max_num_pages; ?>;
    jQuery(document).ready(function(){
    jQuery(window).scroll(function(){
    if ( jQuery(window).scrollTop() == jQuery(document).height() – jQuery(window).height()){
    if(count>total){
    return false;
    }
    else{
    loadMore(count);
    }
    count++;
    }
    });
    });

    function loadMore(pageNumber){
    jQuery(‘a#inifiniteLoader’).show(‘fast’);
    jQuery.ajax({
    url: “<?php bloginfo(‘wpurl’) ?>/wp-admin/admin-ajax.php”,
    type:’POST’,
    data: “action=infinite_scroll&page_no=”+ pageNumber + ‘&loop_file=loop’,
    success: function(html){
    jQuery(‘a#inifiniteLoader’).hide(‘1000’);
    jQuery(“#content”).append(html); // This will be the div where our content will be loaded
    }
    });
    return false;
    }

    </script>

    ————————————————————————
    function wp_infinitepaginate(){
    if (!is_single() || !is_page()):
    $loopFile = $_POST[‘loop_file’];
    $paged = $_POST[‘page_no’];
    $posts_per_page = get_option(‘posts_per_page’);

    # Load the posts
    query_posts(array(‘paged’ => $paged ));
    while(have_posts()):the_post();
    get_template_part( ‘content’ );
    endwhile;

    endif;
    exit;
    }

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Infinite scroll troubleshooting’ is closed to new replies.