Answer the question
In order to leave comments, you need to log in
Why is pagination not working correctly (WordPress)?
Pagination does not work correctly
on the page . Ten pages are displayed. At the same time, the transition to the tenth does not display posts. After switching to the second, the tenth number disappears. This is done using the native function .
Used the code in funtions.php and it partially helped: Php the_posts_pagination ($ args);
function site_request($query_string ) {
if ( isset( $query_string['page'] ) ) {
if ( ''!=$query_string['page'] ) {
if ( isset( $query_string['name'] ) ) {
unset( $query_string['name'] ); }
}
}
return $query_string;
}
add_filter('request', 'site_request');
add_action('pre_get_posts', 'site_pre_get_posts');
function site_pre_get_posts( $query ) {
if ( $query->is_main_query() && !$query->is_feed() && !is_admin() ) {
$query->set( 'paged', str_replace( '/', '', get_query_var( 'page' ) ) );
}
}
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