<?php
if ( is_front_page() ) {
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
}
else {
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
}
$args = array(
'posts_per_page' => 8,
'post_status' => array( 'publish' ),
'post_type' => 'news',
'paged' => $paged,
'page' => $paged,
);
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<div class="news__item">
<div class="news__top">
<p class="news__date"><?php the_time('d.m.Y', $before = '', $after = '', $echo = true); ?></p>
<p class="news__category">Новости</p>
</div>
<div class="news__image"><?php the_post_thumbnail('news-preview', ''); ?></div>
<a href="<?php the_permalink(); ?>"><h3 class="news__title"><?php the_title(); ?></h3></a>
</div>
<?php endwhile; endif; wp_reset_postdata();
custom_pagination($wp_query->max_num_pages, "", $paged);
// echo paginate_links($pagination_args);
?>
function codernote_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', 'codernote_request');
add_action('pre_get_posts', 'codernote_pre_get_posts');
function codernote_pre_get_posts( $query ) {
if ( $query->is_main_query() && !$query->is_feed() && !is_admin() ) {
$query->set( 'paged', str_replace( '/', '', get_query_var( 'page' ) ) );
}
}
<?php
if ( is_front_page() ) {
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
}
else {
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
}
$args = array(
'posts_per_page' => 8,
'post_type' => 'news',
'paged' => $paged,
'page' => $paged,
);
// тут код вывода записей
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<div class="news__item">
<div class="news__top">
<p class="news__date"><?php the_time('d.m.Y', $before = '', $after = '', $echo = true); ?></p>
<p class="news__category">Новости</p>
</div>
<div class="news__image"><?php the_post_thumbnail('news-preview', ''); ?></div>
<a href="<?php the_permalink(); ?>"><h3 class="news__title"><?php the_title(); ?></h3></a>
</div>
<?php endwhile;
endif; ?>
<?php
wp_reset_postdata();
custom_pagination($wp_query->max_num_pages, "", $paged);
?>
https://www.youtube.com/watch?v=vE3m4Y4PTjM&t=907s
В любом случае вам спасибо