WordPress single文章页面实现上一篇/下一篇

同分类下实现上一篇/下一篇代码:

 

<?php if (get_previous_post(true)) { previous_post_link('%link', '%title', true);} else {echo "没有了,已经是最后文章";} ?>

<?php if (get_next_post(true)) { next_post_link('%link', '%title', true);} else {echo "没有了,已经是最新文章";} ?>

 

next_post_link('%link', '%title', true)函数中增加了一个判断:true,就可以限制在同分类。