Using "offset" causes loaded posts to repeat endlessly
-
The main issue is that we need to start the jetpack infinite scroll loop at post #4 instead of the first one. So to do so I have done:
function vc_offset_posts( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'offset', 3 ); return; } } add_action( 'pre_get_posts', 'vc_offset_posts', 10 );
Unfortunately what this does is cause every new click of the load button to load the same set of posts. So on page load we get:
4,5,6,7,8,9
then you click and get
10,11,12,13,14,15
But if you click again you continue to get
10,11,12,13,14,15
Have tested this ad infinitum and it only happens with the offset filter. Other filters don’t cause a problem including posts_per_page etc…
Would love some help.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Using "offset" causes loaded posts to repeat endlessly’ is closed to new replies.