E
E
Egor2020-08-28 12:54:02
WordPress
Egor, 2020-08-28 12:54:02

Pagination crashes on pages, how to fix it?

Pagination crashes on pages (custom post type) due to WooCommerce installation.

If you do not install WooCommerce, everything is ok, as soon as it is installed, it displays a 404 error when clicking on the links.

Page with pagination: https://skazkamini.ru/reviews/

Page code:

<?php 

/*
Template Name: Reviews Template
*/

get_header();

?>


<section class="section-reviews section-page">
  <div class="container">
    <h2 class="section__title">Отзывы о нашей работе</h2>
    <div class="news">

      <?php 

        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $reviews_args = array(
          'paged'          => $paged,
          'post_type'     => 'reviews',
          'posts_per_page' => '1',
          'order'         => 'DESC'
        );

          $reviews_query = new wp_Query($reviews_args); ?>

          <?php echo $paged ?>

          <?php if($reviews_query -> have_posts()) { while ($reviews_query -> have_posts()) : $reviews_query-> the_post();?>

            <div class="news__item card-box dashed">
              <div class="news__photo">
                <a href="#!" data-remodal-target="modal9">
                  <?php echo get_the_post_thumbnail(get_the_ID(), 'post-news')?>
                </a>
              </div>
              <div class="news__info">
                <div class="news__head">
                  <h3 class="news__title"><?php the_title()?></h3>
                  <span class="news__date"><?php echo get_the_date()?></span>
                </div>
                <div class="news__text">
                  <?php the_content()?>
                </div>
                <span class="news__call-span">Хотите сказку - книгу для своего ребёнка? Закажите звонок менеджера!</span>
                <a href="#!" class="news__all-btn">Читать весь отзыв</a>
              </div>
            </div>
      
          <?php endwhile; } wp_reset_postdata(); ?>

      
      
    </div>
    <!-- news -->

    <nav class="pagination">

    <?php
        echo paginate_links( array(
        'show_all'     => false, // показаны все страницы участвующие в пагинации
        'end_size'     => 1,     // количество страниц на концах
        'mid_size'     => 2,     // количество страниц вокруг текущей
        'prev_next'    => false,
        'screen_reader_text' => __( ' ' ),
        'total'     => $reviews_query->max_num_pages,
        'type' => 'list',
        ) );
    ?>

    </nav>
    <!-- pagination -->

    <div class="news__ask-wrap">
      <a href="#!" data-remodal-target="modal8" class="news__ask-btn requisition__form__btn small__shadow__btn big__shadow__btn">Оставить свой отзыв</a>
    </div>



  </div>
</section>
<!-- news section -->


<?php get_footer() ?>

<!-- Reviews photo popup -->
<div data-remodal-id="modal9" class="remodal remodal__review-page" role="dialog" aria-labelledby="modal2Title" aria-describedby="modal2Desc">
  <div class="modal__info__wrapper">
    <div class="modal__close" data-remodal-action="confirm"></div>
    <!-- content -->
    <img src="img/inner-page/child.png" class="remodal__review-img" alt="">   
    <!-- content -->
  </div>
</div>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
its2easyy, 2020-08-28
@e_mooshka

there should not be identical slugs on the site so that there are no conflicts, most likely the page is loaded via the /reviews link because it is more priority than the archive, and at /reviews/page/2 it is already a review archive template, but due to the fact that there are less than two reviews page (less than 10), then the second page does not exist, and gives 404.
You can check if you change the page slug or change rewrite in the post_type settings of the reviews, then save the permalinks. If the problem was in the conflict of slugs, then it will start working

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question