Infinite scroll – help with offset when using meta_query parameter
-
Hello, thanks for all the work done on this great plugin. I just have a question about getting some filtering working with the infinite scroll module.
I used to have a problem using the
orderby
parameter to order posts bycomment_count
and my custom post metas –post_rating
,post_views
. The problem was the starting position (offset) was wrong. It causes a double load first posts instead of carrying on from the last post of the custom WordPress loop. This was a bug that I recently got fixed by looking up here:
https://github.com/Automattic/jetpack/issues/1135
I tried all those solutions and they all work. I’ve got the high priority of theinfinite_scroll_query_args filter
and set an offset:
$args['offset'] = $args['posts_per_page'] * $args['paged'];
I’ve got infinite scroll working with all parameters –
type
,category
,taxonomy
,orderby
. But I’ve got one last problem when using themeta_query
, it’s similar to the orderby bug. For example, this code uses my rating_count post meta to only show posts that have a rating of of at least 1:$args['meta_query'] = array( array( 'key' => 'rating_count', 'value' => 1, 'compare' => '>=', ), );
This meta query works with pagination as normal. But setting up this meta query for infinite scroll using the
infinite_scroll_query_args filter
– it works, except the starting position (offset) is incorrect. It’s like the problem I had with the orderby parameter, but this one is a bit more difficult to fix because the offset starts at a different place depending on how many posts are found. Any ideas of how I can fix this? I think I need a calculation on the offset parameter but I can’t work out what the calculation needs to be.Any help appreciated.
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- This topic was modified 8 years, 2 months ago by .
- The topic ‘Infinite scroll – help with offset when using meta_query parameter’ is closed to new replies.