2016-04-11 33 views
0

在Wordpress中可以设置get_next_post中使用的类别。Wordpress get_next_post设置类别

我有可以有多个类别的文章。

在single.php页面上显示我想要显示的帖子和prev帖子。

我有我想从在single.php中选择类别让我怎么使用,在get_next_post

$the_cat = 'latest'; 

    $next_post = get_next_post($in_same_term = true, $excluded_terms = '', $taxonomy = $the_cat); 

回答

0

在我的文档没有。

$ taxonomy (字符串)(可选)分类标准,如果$ in_same_term为true。在WordPress 3.8中添加。 默认:“类”

依我之见,如果你设置了$in_same_term为false,那么你可以改变$taxonmy

我想,这可能是一个解决办法你,而不是测试,只是一个想法:

<?php 
while ($next_post = get_next_post()) { 
    if (!empty($next_post) && $next_post->catID == 'what you want') { 
     ?> 
     <a href="<?php echo get_permalink($next_post->ID); ?>"><?php echo $next_post->post_title; ?></a>  
     <?php 
    } 
} 
?>