Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8157329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:14:48+00:00 2026-06-06T17:14:48+00:00

On my homepage I have a loop of posts that uses infinite scroll. A

  • 0

On my homepage I have a loop of posts that uses infinite scroll. A user can replace that loop with other loops using ajax like ajax search and so on. My issue is the infinite scroll only works the first time it’s used so if it’s triggered for the main loop then it won’t work again when a new loop replaces the main. Each time a new loop replaces the old the following function is reloaded. So how do I make infinite scroll reset and work every time a new loop is called?

var href = 'first';
$(document).ready(function() {
    $('#boxes').infinitescroll({
        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');
        }
    });
});

I’m using the latest version 2.0b2.120519 of the Pual Irish infinite scroll plugin on a wordpress site.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:14:50+00:00Added an answer on June 6, 2026 at 5:14 pm

    I’m not 100% sure which version of that plugin you’re using, but I checked into the latest distribution and you need to perform two methods to make this work.

    First, in your ajax function, you need to destroy the session on success.

    $.ajax({
      url: 'path/to/something.ext',
      success: function(data){
        //call the method to destroy the current infinitescroll session.
        $('#boxes').infinitescroll('destroy');
    
        //insert the new data into the container from the_loop() call
        $('#boxes').html(data);
    
        //reinstantiate the container
        $('#boxes').infinitescroll({                      
          state: {                                              
            isDestroyed: false,
            isDone: false                           
          }
        });
    
        //call the methods you need on the container again.
        $('#boxes').infinitescroll({
          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');
          }
        });
      }
    });
    

    You could also make it a function, bind to it, and unbind/rebind instead of repeating alot of code, but the code I’ve outlined should be a copy+ paste solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main loop that I replace with other loops when certain icons
I have a little app that have by default youtube as homepage. You can
I have a homepage with four displayed posts and one that is emphasized. The
I have recently made a new homepage for my company so that employees can
I have a slider on homepage, i am trying to load next five posts
I have built a GPS tracker that updates a homepage with its positions (and
We have been using SimplePie on our Magento install to pull our blog posts
Im using wordpress 3.0 here: http://www.adventure-service.com On homepage i am using template that creates
I have links on a homepage that may or may not have attachments associated
I have two different domains that both point to my homepage in the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.