WordPress Plugin WP-PageNavi does not find a second page

0

The pagination appears at the bottom of the page, the limit imposed with the custom query is respected on the first page, but when I access page 2, I fall into a 404. Here is the code:

<?php
    $category 	= get_the_category(); 
    $cat_id	= $category[0]->cat_ID;

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'post_type'        => 'post',
        'orderby'          => 'title',
        'order'            => 'ASC',
        'post_status'      => 'publish',
        'category'         => $cat_id,
        'posts_per_page'   => 3,
        'paged'            => $paged,
    );
    $query = new WP_Query( $args );
?>

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

    //loop

  <?php endwhile; ?>

  <?php wp_pagenavi( array( 'query' => $query ) ); wp_reset_query(); wp_reset_postdata(); ?>

<?php else:?>

    <?php _e('Nenhum conteúdo encontrado!'); ?>

<?php endif; ?>

I noticed that if I put the same value of 'posts_per_page' property in admin panel settings it finds page 2, but the intention of using 'posts_per_page' is the mobility of choosing the number of posts listed for each type of post . Any ideas on the problem?

    
asked by anonymous 08.08.2018 / 15:31

0 answers