PageNavi redirects to 404 when used as archive page

I’m using a page as archive for a custom post type called event.

register_post_type(‘event’, array(
‘labels’ => array(
‘name’ => ‘Événements’,
‘singular_name’ => ‘Événement’,
),
‘public’ => true,
‘has_archive’ => false,
‘hierarchical’ => false,
‘menu_icon’ => ‘dashicons-calendar-alt’,
‘rewrite’ => array(
‘with_front’ => false,
‘slug’ => ‘evenements’
)
));

Then, I defined this page template to template-event.php, where I use the following code to loop through post types.

$args = array(
‘post_type’ => ‘event’,
‘posts_per_page’ => 6,
‘paged’ => get_query_var(‘paged’)
);

$the_query = new WP_Query( $args );

if( $the_query->have_posts() ) :

while ( $the_query->have_posts() ) : $the_query->the_post();

the_title();

endwhile;

wp_pagenavi( array( ‘query’ => $the_query ) );
wp_reset_postdata();

endif;
?>

This code works great for my home.php page, but not for this one.
Any idea why?

Read more here:: PageNavi redirects to 404 when used as archive page

Leave a Reply

Your email address will not be published. Required fields are marked *