I have author pages for each author and I want to see all of their comments (or all of their recent comments) if I click on their nickname. How can I do this? I tried the beneath code, but that does not show the unique comments per user… It just outputs all recent comments from everyone combined, but I don’t want that.
<?php
$author_email = get_the_author_meta( 'user_email' );
$args = array(
'author_email' => $author_email,
'number' => '10'
);
$comments = get_comments($args);
foreach($comments as $comment) :
echo('<li class="comment">' . $somment->comment_content),'<h5><a href='.get_permalink($comment->comment_post_ID).'>', get_the_title($comment->comment_post_ID), '</a></h5>', '<time><em>' . $comment->get_comment_date . '</em></time>', '</li>';
endforeach;
?>
</ul></div>
your problem is using
author_email
, you needuser_id
:i just use similar script.
?>
Check This Show Comments by User ID in WordPress