I'm having trouble making paging work in a POST_TYPE that I created in wordpress, my entire Query is created and returns the posts normally of the "post_type = club", but when adding the pagination, the next pages generate the 404 error.
<ul class="clube-ul w-list-unstyled">
<?php
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
}
elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
}
else {
$paged = 1;
}
$clubeList_args = array(
'posts_per_page' => 2,
'paged' => $paged,
'post_type' => 'clube',
)
?>
<?php $clubeList = new WP_Query($clubeList_args); ?>
<?php if ( $clubeList->have_posts() ) : ?>
<?php while ( $clubeList->have_posts() ) : $clubeList->the_post(); ?>
<li class="clube-li">
...BLABLABLA CRIAÇÃO DO ITEM...
</li>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</ul>
<div class="pagination">
<div class="container">
<div class="pagination-flex">
<?php previous_posts_link( __( 'Anterior', 'gente' ) ); ?>
<?php next_posts_link( 'Próximo', $clubeList->max_num_pages ); ?>
</div>
</div>
</div>