O
O
ololoshka12020-06-27 12:59:23
WordPress
ololoshka1, 2020-06-27 12:59:23

Pagination not working, why?

I display all posts in category-page.php, I adjust
and pagination does not work, tell me what I'm doing wrong

the code
<section class="case">
               <div class="container">
                  <p class="title" data-aos="zoom-in">All Blog Posts</p>
                  <div class="case__inner" data-aos="zoom-in" data-aos-delay="50">
                
                  <?php
            $posts = get_posts( array(
          'numberposts' => 9,
          'category'    => 0,
          'orderby'     => 'date',
          'order'       => 'DESC',
           'post_type'   => 'post',
          'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
        ) );

            foreach( $posts as $post ){
      setup_postdata($post);
        ?>
               <div class="box" data-aos="zoom-in" data-aos-delay="250">
                        <div class="box-image">
                           <picture>
                              
                              <img src="<?php the_post_thumbnail_url(); ?>" alt="">
                           </picture>
                        </div>
                        <div class="box-text">
                           <div class="inner">
                              <div class="inner-category">
                              <?php the_category(); ?>
                              </div>
                              <div class="inner-date">
                              <p><?php the_time('M j, Y'); ?></p>
                              </div>
                           </div>
                           <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        </div>
                     </div>
                     
    <?php
    
        }
// пагинация

wp_reset_postdata(); 
?>
                                 
                  </div>
                  <div class="navigation">
                     <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
           </div>  
               </div>
            </section>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy, 2020-06-27
@Evdokim001

Good afternoon. In order for pagination to work, based on your code, you need to have more than 9 articles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question