admin管理员组文章数量:1333201
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(); ?>
本文标签: Pagination for custom categories template
版权声明:本文标题:Pagination for custom categories template 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742285018a2446774.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论