2011-09-06 115 views
1

我需要一些幫助來顯示一些特定的WordPress帖子。Wordpress - 用wp_query顯示特定帖子

我的網站上的用戶可以點擊「添加到收藏夾」鏈接,然後將該帖子ID作爲數組存儲在該用戶的user_meta表中。

所以,當我把我的author.php模板頁面如下...

<?php 
print_r ($curauth->user_favourite_post) ; 
?> 

...它這個返回...

陣列([0] => 2387 [ 1] => 1307 [2] => 1149 [3] => 1156 [4] => 474 [5] => 50 [6] => 1131 [7] => 1473 [8] => => 2544)

......這都很好。這是用戶'已收藏'的帖子ID。

我的問題是,如何在作者頁面上顯示這些帖子? 我有這個...

<?php 
$my_query = new WP_Query(); 
$my_query->query(array('post__in' => array($curauth->user_favourite_post))); 
while ($my_query->have_posts()) : $my_query->the_post(); 
?> 

<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
<?php endwhile; ?> 

...但它只是顯示所有用戶已被「收藏最多」的職位,不感興趣的。我嘗試了很多不同的方式,他們都只是回覆每一篇文章。

回答

0

嘗試

$my_query->query(array('post__in' => (array) $curauth->user_favourite_post)); 
+0

還不行。這也會返回每個帖子。 – user537137