Pagenavi with archive page
I have some problems in making wp_pagenavi works. I have a custom post archive page in which I activated the function. Here's the code:
?php
// WP_Query arguments
$args = array(
'post_type' = array( 'connazionali' ),
'nopaging' = false,
'paged' = '1',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query-have_posts() ) {
while ( $query-have_posts() ) {
$query-the_post();
the_title();
the_content();
}
wp_pagenavi( array( 'query' = $query ));
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?
The pagination displays correctly but when I click on second page, the same three articles are displayed (even if the url /page/2 is correct). I noticed this problem only on archive page, while on category page it is working fine.
Ho can I solve the problem?
Thank you!
Topic plugin-wp-pagenavi wp-query pagination Wordpress
Category Web