WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need some help with displaying some specific WordPress posts.

User's on my site can click on an 'Add to favorite' link which will then store that post ID in the user_meta table for that user as an array.

So when I put the following in my author.php template page...

print_r ($curauth->user_favourite_post) ;

... it returns with this...

    [0] => 2387
    [1] => 1307
    [2] => 1149
    [3] => 1156
    [4] => 474
    [5] => 50
    [6] => 1131
    [7] => 1473
    [8] => 2388
    [9] => 2544

... which is all good. This is the post ID's that the user has 'Favorited'.

My question is, how can I display these posts on the author page? I have this...

$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; ?>

... But it just displays all of the posts and not the ones that have been 'Favorited' by the user. I've tried a number of different ways and they all just return every post.

share|improve this question
if you copied and paste the code, fix the user favourite _post in the second line, you are using user_favourite_post – andresmijares25 Nov 17 '11 at 3:55

Could be because you are passing an array of array try this:

$my_query = new WP_Query();
$my_query->query(array( 'post__in' => $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; ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.