• Hello
    im using jetpack infinite scroll and it works great. Im using Twenty Sixteen theme so its very easy to use infinite scroll.

    However, im using custom query in my category template for sorting post using form and then im using query posts to retrieve posts:

    $order = "&order=DESC";
      if ($_GET['sort'] == 'newest') { $order = "&orderby=date";  }
      if ($_GET['sort'] == 'lowest-price') { $order = "&order=ASC&orderby=meta_value_num&meta_key=price";  }
     if ($_GET['sort'] == 'popular') { $order = "&orderby=meta_value_num&meta_key=views";  }
        if ($_GET['sort'] == 'highest-price') { $order = "&orderby=meta_value_num&meta_key=price";}
    
    query_posts($query_string . $order);
     if ( have_posts() ) : 
    
    			// Start the Loop.
    			while ( have_posts() ) : the_post();

    The code works and whenever someone select the dropdown option, my url will change like: http://www.mysite.com/category/men?sort=highest-price if someone select “Highest price” in dropdown form. The posts then will sort by “highest price” from “Men” category.
    Problem is if i using jetpack infinite scroll, when the scroll load, it will only retrieve the last post….
    so the first loaded posts are sorted and the post loaded by infinite scroll is only 1 post and that is the last post in that category…

    Is there any solution for this?

    Thanks!

    https://wordpress.org/plugins/jetpack/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter crovinca

    (@crovinca)

    here is the code for the dropdown form

    <form method="get" id="price-form">
    <select id="sortby" name="sort" onchange='this.form.submit()'>
        <option value="newest"<?php selected( $_GET['sort'],'newest', 1 ); ?>>Newest</option>
        <option value="popular"<?php selected( $_GET['sort'],'popular', 1 ); ?>>Popular</option>
        <option value="lowest-price"<?php selected( $_GET['sort'],'lowest-price', 1 ); ?>>Lowest price</option>
        <option value="highest-price"<?php selected( $_GET['sort'],'highest-price', 1 ); ?>>Highest price</option>
      </select>
    </form>
    Thread Starter crovinca

    (@crovinca)

    i tried to use wp_query for quick and simple orderby meta key, but it still return the last post. Here is the code i tried:

    $args = array(
        'meta_key' => 'price',
        'orderby' => 'meta_value_num',
    'paged' => $paged
        'order' => 'DESC'
            );
    $the_query = new WP_Query( $args ); 
    
    if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post();

    Is jetpack infinite scroll not work with orderby or meta key? 🙁

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    The infinite_scroll_query_args filter could help you get around this issue. You can read more about it here:
    https://github.com/Automattic/jetpack/issues/1135#issuecomment-65706295

    If you can’t seem to get this to work, do not hesitate to comment on that GitHub issue!

    Thread Starter crovinca

    (@crovinca)

    Hello Jeremy, thanks for your response.
    I’ve tried that filter too, but it still return last post… i set the priority to 100 too and still… infinite scroll return the last post when it loaded new set of post…

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Thanks for giving it a try.

    I’m afraid you’re facing the issue that was reported on the GitHub issue I linked to earlier. Could you comment there and add as many details as possible about your Infinite Scroll implementation, so we can look into this?

    Thanks!

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

The topic ‘Jetpack infinite scroll load only last post’ is closed to new replies.