WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Infinite Scroll and custom queries

[Resolved] Infinite Scroll and custom queries

  • jacob0601
    Member

    @jacob0601

    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/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jeremy Herve
    Jetpack Mechanic

    @jeherve

    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! 🙂

    jacob0601
    Member

    @jacob0601

    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!

    Hey,

    Any news on this or maybe some temporary workarounds?

    Thank you.

    jacob0601
    Member

    @jacob0601

    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!

    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.

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Infinite Scroll and custom queries’ is closed to new replies.