It looks like there’s two problem with the code you’re trying to use. The first is AUTHOR_ID
. Unless you have this defined somewhere else, then this is going to cause an undefined constant error. The second one is that there should be a closing PHP tag ?>
before <?php endwhile; ?>
.
Another thing is, that doing WP_Query
is a bit unnecessary as you can pass the user ID as a parameter to the WP_Comment_Query
directly.
For example on author.php
template you could do this,
<?php
$query = new WP_Comment_Query( array(
'user_id' => get_queried_object_id()
) );
foreach ($query->comments as $comment) {
echo '<p>' . $comment->comment_content . '</p>';
}
?>
EDIT
To get comments from the author’s posts, use post_author
parameter.
<?php
$query = new WP_Comment_Query( array(
'post_author' => get_queried_object_id()
) );
foreach ($query->comments as $comment) {
echo '<p>' . $comment->comment_content . '</p>';
}
?>