So I am trying to make a query on the home page that supports pagination, how ever when I move to any other pages, I get the 404 page.
<div class=”postCardWrapper”>
<?php wp_reset_postdata();?>
<?php
$args = array(
‘post_type’ => ‘user-post’,
‘posts_per_page’ => 5,
);
$the_query = new WP_Query( $args ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php
// Template part controls what each one looks like
get_template_part( ‘template-parts/custom-post-view/post-card-loop’);
?>
<?php
endwhile;
wp_pagenavi( array( ‘query’ => $the_query ) );
?>
<?php wp_reset_postdata();?>
<?php
endif;
?>
</div>
This is what my code looks like currently. I’ve tried to do this as well without using plugins and got the same issue. Adding
‘paged’ => 2,
to the query does show the content I expect for the second page, but using any form of pagination buttons brings me to the 404 page. the URL for the second page displays as “site.name.local/?paged=2”
[ad_2]