Pagination for custom categories template

I'm a newbie with wordpress theme creation. I want to create a custom category.php file, I've implemented the

I'm a newbie with wordpress theme creation. I want to create a custom category.php file, I've implemented the loop and it will display the last 8 posts. I have some fake posts to test if all works well, but I'm not able to add a pagination to the category template I have created.

How I can implement the pagination?I'm thinking to use an infinite scrll using the wp rest api but any other solution will be appreciated. This is the code I'm using now, the previous link and the next are not displayed

<?php get_header(); ?>
<?php $current_cat = get_queried_object(); ?>
<div class="container mt-5 pt-5">
    <div class="row m-0">
        <div class="col-sm-12 col-md-12 col-lg-12 mt-2 mb-2">
            <p class="text-uppercase font-weight-bold mt-2 mb-2 section-title"><?php echo $current_cat->cat_name; ?></p>
        </div>  
<?php if( have_posts() ): while( have_posts() ): the_post(); ?>        
        <div class="col-sm-12 col-md-3 col-lg-3 h-100 mt-2 mb-2">
            <img class="img-fluid w-100 h-100" src="<?php echo the_post_thumbnail_url(); ?>">
            <a class="h5 mt-2 mb-2" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
            <small class="text-muted d-block"><?php echo get_the_date('j F Y' ,$post->ID); ?></small>
        </div>
    <?php echo next_posts_link(); // not working?>
    <?php echo previous_posts_link(); // not working?>
<?php endwhile; endif; ?>    
    </div>
</div>

<?php get_footer(); ?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742285018a4415168.html

相关推荐

  • Pagination for custom categories template

    I'm a newbie with wordpress theme creation. I want to create a custom category.php file, I've implemented the

    21小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信