Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I don't know if i can explain this..

I want to create a Page where the comments of specific user is listed. like this format...

User Name

       Post Tilte
       - comment
       - comment
       - comment


       Post Tilte
       - comment
       - comment
       - comment

well, im not looking exactly as that format, but I want something similar to that. I already have a page where all the posts by specific user is listed, now this time I want list of comments. Is that possible? Or is there any available plugin that can provide me that function? Any answers or recommendations will be appreciated. Thanks :)

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can use the get_comments function to retrieve comments from a specific user.

$comments = get_comments( array( 'user_id' => 1 ) );
foreach( $comments as $comment ) {
    $post_id = $comment->comment_post_ID;
    $post = get_post( $post_id );
    setup_postdata( $post );
    echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
    echo $comment->comment_author . '<br />' . $comment->comment_content;
}
share|improve this answer
    
Thanks @chris, that should do my problem, but Is there a way to add the Title of the post? with link to the post's permalink. Sorry if im asking too much. –  markyeoj Jul 20 '12 at 4:45
    
ok, sorry I think I just need to refer to the codex :) thank you. –  markyeoj Jul 20 '12 at 4:48
1  
See edit. get_comments returns the post id for the original post the comment was made to. Using get_post and setup_postdata. You can access the template tags referencing the original post. –  Chris_O Jul 20 '12 at 4:54
    
Thank you so much.. guys :) so appreciated :D cheers.. –  markyeoj Jul 20 '12 at 7:07

Your Answer

 
discard

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.