1

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 :)

1 Answer 1

4

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;
}
3
  • 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
    Commented Jul 20, 2012 at 4:45
  • ok, sorry I think I just need to refer to the codex :) thank you.
    – markyeoj
    Commented Jul 20, 2012 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
    Commented Jul 20, 2012 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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