M
M
Max_Borisov2016-02-16 13:39:22
WordPress
Max_Borisov, 2016-02-16 13:39:22

Pagination in wordpress?

Made pagination using wp-pagenavi. There are no problems in the page.php, index.php template, everything works correctly. Problem with category.php template. The number of pages displays correctly, but when you go to any page except the first one, it gives 404. I also tried the_posts_pagination (); and the solution from here is dimox.name/wordpress-pagination-without-a-plugin/. All the same. Here is the code:

<?php 
      $cat = get_the_category();
      $current_page = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $params = array(
        'posts_per_page' => 1, 
        'cat' => $cat[0]->cat_ID,
        'paged'           => $current_page
      );
      query_posts($params);
      
      while(have_posts()): the_post(); ?>
        
        <div class="work-item">
          <a href="<?php the_permalink(); ?>">
            <?php the_post_thumbnail(); ?>
          </a>
          <a href="<?php the_permalink(); ?>" class="item-title"><?php the_title() ?></a>
        </div>

      <?php endwhile; ?>
    <?php endif; ?>
    <div class="pagenavi"><?php wp_pagenavi(); ?></div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marina Lebedeva, 2016-02-16
@Margo_shka

Oooh, same problem as I wrote yesterday.
Everything will work if post_per_page=10.
By default, wordpress calculates and accepts pages for 10 posts.
And pagination is set by post_per_page

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question