2014-01-19 20 views
0

我使用下面的代碼來創建一個鏈接到下一篇文章,這裏$hidden_categories是包含我想從一個鏈接排除類別的ID的數組。excluded_categories不get_next_post工作()

<?php 
$next_post = get_next_post(false, implode (", ", $hidden_categories)); 
if (!empty($next_post)): ?> 
    <a href="<?php echo get_permalink($next_post->ID); ?>"><?php echo $next_post->post_title; ?></a> 
<?php endif; ?> 

但它不排除我想排除的類別的職位。這段代碼有什麼問題嗎?

回答

0
<?php 
$hidden_categories_array = implode("," , $hidden_categories); 
$next_post = get_adjacent_post(false, $hidden_categories_array, true); 
if (!empty($next_post)): ?> 
    <a href="<?php echo get_permalink($next_post->ID); ?>"><?php echo $next_post->post_title; ?></a> 
<?php endif; ?>