PHP - WordPress的上一篇文章链接显示在最后一篇文章

问题描述:

基本上下面的代码显示了下一个类别的帖子,而不是显示。PHP - WordPress的上一篇文章链接显示在最后一篇文章

我希望这消失,如果在最后一个帖子循环。

然而,接下来一个人工作,我怎么指望它没有显示它,如果它是在第一的职位:

<div class="post-next"><?php next_post_link('%link', true); ?></div> 

这是一个简单的while循环没有crazyness:

<?php 
    // Start the loop. 
    while (have_posts()) : the_post(); 
     // Like so content in side 
    endwhile; 
?> 

其他人有这个问题吗?

顺便说下一篇文章不属于同一类别。

这可能是由于这样的事实,WordPress的只是看到帖子和自定义文章类型,同样的事情,除非你以其他方式告诉它。快速浏览过的Codex显示,有属性,你可以用它来限制上一页/下一页链接,分类等

试试这个:

<?php next_post_link($format, $link, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category'); ?> 

使用分类选项,您可以限制链接只显示1个特定类别,因此您不应在指定类别的最后一页上看到链接。

+0

对不起杰里米更好的描述我的问题 – MaxwellLynn

我认为你需要做true第三个参数是这样的:

<div class="post-previous"><?php previous_post_link('%link', null, true); ?></div> 

https://codex.wordpress.org/Function_Reference/previous_post_link

+0

哇,我觉得愚蠢。谢谢... – MaxwellLynn