WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination


This my code for sub category archive page:

                        <?php $my_query = new WP_Query( array( 'posts_per_page' => 12, 'post_type' => 'post', 'paged' => get_query_var( 'paged' ), 'post_status' => 'publish', 'category__and' => array( 2 ) ) ); ?>        
                        <?php if ($my_query->have_posts()) : ?>
                        <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

                        //Contents Here//

                        <?php endwhile; ?><?php endif; ?>                   
                        <?php wp_reset_postdata(); ?>

And this is my pagination code:

        <?php global $wp_query; if ($wp_query->max_num_pages > 1) : ?>  
        <div class="col-xl-12 col-lg-12 col-md-12">                                 
            <div class="mt-40 mb-60">
                <?php mytheme_pagination(); ?>
        <?php endif; ?> 

Now I have 1 empty extra page number in pagination of my archive page.

For example I have only 3 pages of contents by I can See a number 4 link in pagination numbers who open’s an empty page without any posts in there.

PS: There is not any problem with Category Archive page and it’s only appears in SUB-Category archive page.

Can you help me please?

emco 2 months 0 Answers 5 views 0

Leave an answer