404 error next-page [2] PageNavi custom type taxonomy

I have a custom post type called pizza with a custom taxonomy called genero.

mypage/pizza/peperoni/

When I click subsequent paginated page links (e.g. [2], [3], [next])

mypage/pizza/peperoni/page/2

The post is displayed correctly, but when I try to go to next-page [2], takes me to an 404 page

my loop

?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 2; 
$args = array(
  'posts_per_page' = 2,
    'order' = 'DESC',
    'tax_query' = array(
        array(
            'taxonomy' = 'genero',
            'field' = 'slug',
            'terms' = 'peperoni',
             'paged' = $paged,
        )
    )
);
$query = new WP_Query( $args );
if ( $query-have_posts() ) {
    while ( $query-have_posts() ) {
        $query-the_post();?

?php the_title(); ?
?php                       
    }
}
wp_pagenavi( array( 'query' = $query ) );
wp_reset_query();  // Restore global post data stomped by the_post().

?

Topic plugin-wp-pagenavi custom-taxonomy pagination 404-error custom-post-types Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.