• Resolved jonas088

    (@jonas088)


    I’m looking for a solution to pass different query args for infinite scroll based on the page the user is.

    E.G.: If the user is on a search page, post results should be ordered in different order than on other pages.

    I’ve tried the infinite_scroll_query_args function:

    function jetpack_infinite_scroll_query_args( $args )
    {
    if  (is_search()) {
            $args['order'] = 'DESC';
            return $args;
        }
    
    else
    {
        $args['order'] = 'ASC';
        return $args;
    }
    
    }

    I guess, that “is_search()” will not work, as it is outside of the loop!? Any idea, how to solve this?

    Thanks for your reply in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Could you try making these checks to the function you created as the render parameter when you declared support for Infinite Scroll? You should be able to load a different loop there depending on the page you’re on, and apply different changes to each loop.

    Let me know how it goes.

    Thread Starter jonas088

    (@jonas088)

    Hi Jeremy,

    thanks for you feedback. Your solution works fine. The only important thing is to set paged parameter in the custom render query.

    Thanks again 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Infinite Scroll: query args based on current page’ is closed to new replies.