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 );
logging
is neither aboutlogged in
content or related in any other way to your question. Thanks.