I need a query that get all comments from only the posts where the currently logged in user is the author.

Each user (author) can post a new post. Then I need to show a list of their own posts ( that already works). Now I want a list of all comments (on the currently logged in users posts). So the author has a quick overview of all comments on their posts.

  • Please care about your tags. logging is neither about logged in content or related in any other way to your question. Thanks.
    – kaiser
    Oct 23, 2014 at 21:21

2 Answers 2


Using the @shanebp ideas of using get_comments:

$args = array(
    'post_author' => get_current_user_id(), // It will use the current logged in use to grab the comments
$comments = get_comments( $args );

// Referer to http://codex.wordpress.org/Function_Reference/wp_list_comments
$list_args = array(
    'reverse_top_level' => false // Show the latest comments at the top of the list
wp_list_comments( $list_args, $comments );

This will display the list of comments done on posts from one user.


Actually the WP_Comment_Query class supports pretty much everything you want. You might want to use either post_author to fetch the comments or user_id. Both do pretty much the same thing. As you can see, the post_status is publish and only for the post type post. Alter the arguments as you need them.

if ( ! is_user_logged_in() )
    return print 'Nothing to see here';

$comment_query = new WP_Comment_Query;
$comments = $comment_query->query( array (
    'status'         => 'approve',
    'type'           => 'comment',
    // 'post_author'    => get_current_user_id(),
    'post_status'    => 'publish',
    'post_type'      => 'post',
    'user_id'        => get_current_user_id(),
    'number'         => 20,
    'offset'         => 0,
    'order'          => 'DESC',
    'orderby'        => 'comment_date',
    'count'          => true,
) );
foreach ( $comments as $comment )
    var_dump( $comment );

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.