"next_posts_link" in post_type wordpress generates error 404

Asked

Viewed 52 times

0

I’m having trouble running the paging on a POST_TYPE I created in wordpress, all my Query is created and returns the posts normally from "post_type=club", but when adding the paging, the next pages generate error 404.

<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>

1 answer

0


Browser other questions tagged

You are not signed in. Login or sign up in order to post.