2016-04-11 44 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 
    } 
} 
?>