I am trying to display authors comments on their profile page (author.php), however both codes I tried seem to display everyone's comments. Also the second code is suppose to link to the specific comment, but instead it does nothing. Also the comments id is already added to the comments output and it prints fine. Any help is greatly appreciated.
// Method 1
<ul class="authpcom">
<?php
$author_email = get_the_author_meta( 'user_email' );
$args = array(
'author_email' => $author_email
);
$comments = get_comments($args);
foreach($comments as $comment) :
echo('<a href=" ' . get_permalink($comment->post_ID) . ' " rel="external nofollow" title=" ' . $title . ' ">' .$title . '</a><br />' . $comment->comment_date . '<br /><li>' . $comment->comment_content . '</li>');
endforeach;
?>
</ul>
// Method 2
<?php $comments = get_comments(); ?>
<ul id="recent_comments">
<?php foreach ($comments as $comment) { ?>
<li><p><strong><?php
$title = get_the_title($comment->comment_post_ID);
echo get_avatar( $comment, '45' );
echo strip_tags($comment->comment_author); ?></strong> commented on <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php echo $comment->comment_ID; ?>" rel="external nofollow" title="<?php echo $title; ?>"> <?php echo $title; ?></a>: <?php echo wp_html_excerpt( $comment->comment_content, 45 ); ?> (...)</p></li>
<?php } ?>
</ul>
Used on comment output divs -
$comment->comment_ID
object(WP_User)#345 (7) { ["data"]=> object(stdClass)#344 (10) { ["ID"]=> string(1) "2" ["user_login"]=> string(6) "agent1" ["user_pass"]=> string(34) "$P$BXUSPFSBfmyIrjZ2YUnbIs1GwjkdH50" ["user_nicename"]=> string(6) "agent1" ["user_email"]=> string(19) "[email protected]" ["user_url"]=> string(0) "" ["user_registered"]=> string(19) "2015-07-25 10:33:27" ["user_activation_key"]=> string(0) "" ["user_status"]=> string(1) "0" ["display_name"]=> string(9) "John Paul" } ["ID"]=> int(2) ["caps"]=> array(1) { ["agent"]=> bool(true) } ["cap_key"]=> string(15) "tr_capabilities" ["roles"]=> array(1) { [0]=> string(5) "agent" } ["allcaps"]=> array(2) { ["read"]=> bool(true) ["agent"]=> bool(true) } ["filter"]=> NULL }