WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] Infinite Scroll and custom queries (7 posts)

  1. jacob0601
    Member
    Posted 1 year ago #

    Can IS handle these properly?

    I change the order of my front page posts via:

    add_filter( 'pre_get_posts', 'custom_query_order' );
    
    function custom_query_order( $query ) {
    
    if ( $query->is_home() && $query->is_main_query() ) {
    	$query->set( 'meta_key', 'post_views_count' );
    	$query->set( 'orderby', 'meta_value_num' );
    	$query->set( 'order', 'DESC' );
      }
    
        return $query;
    }

    This works fine locally but on live, it repeats posts and excludes some.

    http://wordpress.org/extend/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    I checked with our Infinite Scroll expert, and although IS should handle custom queries in most situations, it won't work with custom ordering at the moment. We're working on some improvements to Infinite Scroll though, so keep an eye on the changelog, you might get what you're looking for in a future Jetpack release! :)

  3. jacob0601
    Member
    Posted 1 year ago #

    Ahh that explains a lot:) I was actually wrong about it being fine locally; it's messed up on both my local and live test site (was just more apparent on live). I've sent you guys a message via the jetpack messaging system if you care to take a look (although we know why it is not working now).

    Dang, I really liked your Infinite Scroll too:/

    Cheers!

  4. akis
    Member
    Posted 11 months ago #

    Hey,

    Any news on this or maybe some temporary workarounds?

    Thank you.

  5. jacob0601
    Member
    Posted 11 months ago #

    Hey Akis,

    I went with a diff plugin for the IS, until Jetpack supports the custom queries. As soon as Jetpack's IS can handle this without hacking, I'm going back.

    I am almost positive other people are getting it work already though. This website seems to be using Jetpack IS and using custom sorting without any issues; so it can be done. Not sure how they got it to work though...

    Cheers!

  6. akis
    Member
    Posted 11 months ago #

    Thank you for your reply, Jacob.
    I'll try the other plugin until Jetpack fixes the issues.

    The website you mentioned seems to be using a modified version of infinity.js also (based on waypoints plugin) probably not related to our problem though.

  7. akis
    Member
    Posted 11 months ago #

    As a temporary solution I have added the following inside infinity.php:773

    'orderby' => 'meta_value_num id',
    'meta_key' => 'post_views_count',
    'offset'=> self::get_settings()->posts_per_page * $page

    It seems to work well.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic