0

I'm creating the category template for a custom theme. With this code I'm able to get the last six posts of the news category, I need to add pagination links at the bottom of the page, How I can do this? I've tried with the wordpress bundled function, but nothing is displayed.

<?php get_header('news'); ?>

<div class="container-fluid mt-5 pt-5 p-0">
    <div class="row m-0 pt-5">
<?php if( have_posts() ): while( have_posts() ): the_post(); ?>
    <div class="col-sm-12 col-md-4 col-lg-4 p-0">
        <a class="text-decoration-none stretched-link" href="<?php the_permalink(); ?>">
        <img class="img-fluid w-100 h-100" src="<?php the_post_thumbnail_url(); ?>" >
        <div class="card-img-overlay">
            <h4 class="text-white"><?php the_title(); ?></h4>
            <h4 class="btn btn-outline-light text-uppercase rounded-0" style="border-width:2px;"><?php _e('Leggi'); ?></h4>
        </div>
        <div class="overlay position-absolute"></div>
        </a>
    </div>
    <?php previous_posts_link(); ?>
    <?php next_posts_link(); ?>   
<?php endwhile; endif; wp_reset_postdata(); ?>
    </div>
</div>
<?php get_footer(); ?>
  • previous_posts_link() and next_posts_link() need to be outside the while:, endwhile; loop. Also wp_reset_postdata() is not required in this context. – Jacob Peattie May 7 '20 at 10:22
  • Ok, I will put them outside the loop. If I want to implement a bootstrap 4 pagination, is there any good question or link that I can follow? – sialfa May 7 '20 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.