• I’m using JetPack Infinite Scroll on a new theme, and all is well. Except the search results page. By default, it didn’t work on the search results page but I managed to fix that by using the infinite_scroll_archive_supported filter.

    function wh_infinite_scroll_support() {
    	$supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() );
    	return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'wh_infinite_scroll_support' );

    However. When scrolling on to page two, the posts loaded are from the default loop as apposed to the second page of results from the search loop. It doesn’t appear to be maintaining the search query string. Has anyone seen this before and know of a solution?

    Any help, greatly received.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    What happens when you try to switch to another theme, like Twenty Twelve? Do you still experience the issue?

    That would allow us to know if the problem is caused by Infinite Scroll or by the loop in your search template file, maybe.

    Let me know how it goes!

    Thread Starter John Wilson

    (@johnwilsonuk)

    Yeah, when I add the above filter to Twenty Twelve via functions.php the same happens, page 2 shows page two of the main loop not page two of the search results.

    If I disable this filter & click more posts in Twenty Twelve, it shows the correct second page of results.

    Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    I now recall this Infinite Scroll bug. We’ve been working on a fix in #1706-plugins. Could you try to apply the patch I just uploaded to your version of Jetpack?

    Let me know if it fixes the problem.

    Thread Starter John Wilson

    (@johnwilsonuk)

    Well, I’ve done that. Changed both the infity.php & infinity.js and the same is happening. I tried using both my custom theme & Twenty Twelve and the problem persists in both.

    Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    Thanks for trying! We’re still working on it, so you might want to keep an eye on the ticket to follow our progress.

    I will pot again here as soon as the problem is fixed!

    Thread Starter John Wilson

    (@johnwilsonuk)

    Righto, don’t suppose you know how long it’ll be? I’m sure there’s a million & one other things on the list first, but worth a shot πŸ™‚

    Thanks for trying & looking into it for me.

    Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    I don’t have an ETA I’m afraid, but you can add yourself in cc of the ticket I linked to earlier, and you’ll receive an email every time one of us adds a comment, or commits a fix related to that ticket.

    Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    Would you mind trying to replace your version of Jetpack with this one, and let me know if it helps?
    http://i.wpne.ws/QvdB

    Thanks!

    Thread Starter John Wilson

    (@johnwilsonuk)

    We’re getting closer. The More Posts link, when clicked appears to remember the search terms however the returned posts don’t appear right, it’s just repeating the first 3 posts again then breaks.

    Also, the infinite scroll only now seems to work on the homepage, it doesn’t work on the taxonomy archives. Now, no longer displaying extra posts.

    Tried both these with TwentyTwelve too with different results. On the search, page two of the infinite scroll returns page 1’s results again, then page 3 shows page two’s results and so on.

    The infinite scroll works on the taxonomy archives just fine.

    Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    Thanks for trying again!

    The patch does work on my test site, so I’m not sure why it doesn’t work on your end. Did you make any changes to the Twenty Twelve theme, or do you use other plugins that may conflict with Jetpack?

    Jeremy Herve

    (@jeherve)

    Jetpack Mechanic πŸš€

    Could you also try to use this new version of Jetpack, including another patch?
    http://i.wpne.ws/Qy0a

    Thanks!

    Thread Starter John Wilson

    (@johnwilsonuk)

    Sorry for the late reply, been away for a couple of weeks. Just downloading & trying this now. Will let you know how I get on.

    Cheers!

    Just checking if there have been any updates on this issue? I have the same problem and use the same code in my functions.php file. The infinite_scroll_archive_supported fix worked for the archives but not for is_search().

    I want to try this update as well but I don’t want to muck things up by doing it wrong. I already have Jetpack installed, so do I manually upload the individual files or can I install these through the WordPress plugin installer?

    I tried updating my Jetpack, but it looks like I already have the most recent version ( v.2.5? ). Then I use this code to activate infinite scroll on search pages (it also deactivates infinite scroll in WooCommerce).

    function tweakjp_custom_is_support() {
        $supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || isset($_GET['site_section']) || is_search() ) && ( !is_woocommerce() );
    
        return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );

    The result is that the home page and archives scroll correctly but the search pages still load the homepage posts.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘JetPack Infinite Scroll on Search Results Page’ is closed to new replies.