Could you let me know how you added Infinite Scroll support to your theme? Could you also try to switch to one of the default themes for a few minutes, and let me know if you experience the same problem there?
Thanks!
It works with default theme.
I added support to my theme using this:
add_theme_support('infinite-scroll', array(
'type' => 'scroll',
'container' => 'content',
'footer' => false,
'render' => 'my_category_render_loop',
'posts_per_page' => 20
));
Theme doesn’t have own loops, it is normal category archive loop with modified sorting (uses custom field), modification is done on pre_get_posts as it should be.
I have debugged what is happening on each AJAX request, and in the Infinite Scroll query() method, page is never set, and offset is never used. JavaScript Infinite Scroll generates in page to get query parameters has ‘offset’ set to current page, and that is OK, and page is not set there, and AJAX always sends page as 1. I added one changes: to set page to current page in JS, and it is working. Why is offset page set and never used, I am not sure.
Milan
it is normal category archive loop with modified sorting (uses custom field), modification is done on pre_get_posts as it should be.
Could you paste the code you used here, so I can run some tests on my end?
Thanks!
This is what is pre_get_posts function:
function my_pre_get_posts($query) {
$query->set('orderby', 'meta_value_num');
$query->set('meta_key', 'event_date');
}
Milan
Could you try to add these parameters to Infinite Scroll as well, as explained here:
https://wordpress.org/support/topic/jetpack-infinite-scroll-breaks-sort-order?replies=4#post-4738951
Let me know if it helps.