"next_posts_link" in wordpress post_type generates error 404

0

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>
    
asked by anonymous 22.11.2018 / 19:12

1 answer

0

I was able to solve it by creating a "custom_pagination", according to another question that can be found in the link: link

    
22.11.2018 / 20:18