Ошибка 404 при переходе с пагинации
Это очень распространенная ошибка. У меня проблема заключается в том, что один и тот же код пагинации, работает корректно на архивной странице archive-blog.php, но выдает 404 ошибку при переходе на вторую страницу записей на странице категории, используя шаблон archive.php (category.php тоже выдает ошибку ). Очень прошу помочь сообщество. Перепробовал кучу разных вариантов и ни один не заработал.
archive-blog.php (Здесь работает)
<?php
/**
* The template archive pages
*/
get_header( 'blog' );
?>
<main class="bg-white" style="margin-top: 60px; padding-bottom: 30px;">
<div class="container">
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}
?>
</div>
<div class="row">
<div class="title-classic col-12">
<h2 class="h-text-heading text-center unselectable"><?php echo "Наш блог" ?></h2>
</div>
<div class="col-12">
<div class="grid-container">
<?php
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$idx = 1;
$args = [
'post_type' => ['post', 'blog'],
'posts_per_page' => 7,
'paged' => $paged,
'order' => 'DESC',
'orderby' => 'date'
];
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
$post_id = get_the_ID();
$thumb_size = 'thumbnail';
$thumb_url = get_the_post_thumbnail_url( $post_id, $thumb_size );
?>
<a href="<?php the_permalink() ?>" class="<?php echo "post-$idx "; if ( 4/$idx === 4 ) echo "focus-post" ?> blog-card-item d-flex justify-content-center align-items-center">
<img class="blog-card-item__thumb" src="<?php echo $thumb_url ?>" alt="">
<p class="blog-card-item__title text-center unselectable"><?php the_title(); ?></p>
</a>
<?php $idx++ ?>
<?php
endwhile;
?>
</div>
</div>
<div class="col-12">
<?php
$big = 999999999; // уникальное число
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages,
'type' => 'list'
) );
?>
</div>
<?php wp_reset_postdata() ?>
</div>
</div>
</main>
<?php
get_footer();
?>
archive.php / category.php (Здесь выдает 404)
<?php
/**
* The template archive pages
*/
get_header( 'blog' );
?>
<main class="bg-white" style="margin-top: 60px; padding-bottom: 30px;">
<div class="container">
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}
?>
</div>
<div class="row">
<div class="title-classic col-12">
<h2 class="h-text-heading text-center unselectable"><?php single_cat_title()?></h2>
<p class="p-text-heading text-center unselectable"><?php category_description() ?></p>
</div>
<div class="col-12">
<div class="grid-container">
<?php
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$idx = 1;
$args = [
'post_type' => ['post', 'blog'],
'posts_per_page' => 7,
'paged' => $paged,
'order' => 'DESC',
'orderby' => 'date'
];
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
$post_id = get_the_ID();
$thumb_size = 'thumbnail';
$thumb_url = get_the_post_thumbnail_url( $post_id, $thumb_size );
?>
<a href="<?php the_permalink() ?>" class="<?php echo "post-$idx "; if ( 4/$idx === 4 ) echo "focus-post" ?> blog-card-item d-flex justify-content-center align-items-center">
<img class="blog-card-item__thumb" src="<?php echo $thumb_url ?>" alt="">
<p class="blog-card-item__title text-center unselectable"><?php the_title(); ?></p>
</a>
<?php $idx++ ?>
<?php
endwhile;
?>
</div>
</div>
<div class="col-12">
<?php
$big = 999999999; // уникальное число
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages,
'type' => 'list'
// ) );
?>
</div>
<?php wp_reset_postdata(); ?>
</div>
</div>
</main>
<?php
get_footer();
?>