Answer the question
In order to leave comments, you need to log in
Why does pagination work when hiding pinned posts in a loop?
9 posts are given
, 4 of them are attached and are displayed by a separate request
, the rest of the posts should be displayed as usual with pagination of 6 pieces.
The loop displays 5 posts and a link appears to the second page, which shows an empty feed.
how to fix it?
logically, there is 1 more place for a post, and in general, pagination should not take into account attached articles when paginating,
the cycle code is as follows:
$sticky = get_option( 'sticky_posts' );
$paged = get_query_var( 'paged' ) ?: 1;
$query = new WP_Query( array(
'ignore_sticky_posts' => 1,
'post__not_in' => $sticky,
'posts_per_page' => 6,
'post_type' => 'post',
'paged' => $paged
) );
while( $query->have_posts() ){ $query->the_post();
include ('parts/content-loop.php');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question