0

I have a code that listing comments by author. I use it in author.php. It list comments perfectly but if the author has no comments it shows other authors comment links.

the code

<?php
$args = array(
    'user_id' => get_the_author_meta('ID'),
    'number' => 5, // how many comments to retrieve
    'status' => 'approve'
    );

$comments = get_comments( $args );

if ( $comments )
{

    foreach ( $comments as $c )
    {
    $output.= '<li">';
    $output.= '<a href="'.get_comment_link( $c->comment_ID ).'">';
    $output.= get_the_title($c->comment_post_ID);

    $output.= "</a></li>\n";
    }
    echo $output;
} else { echo "There is no comment yet.";}
?>

i want to see here if author has no comment: else { echo "There is no comment yet.";}

2 Answers2

0

Your code looks fine. Are you sure the get_the_author_meta('ID') function returns the correct value?

Raf
  • 352
  • 2
  • 11
0

I fixed it by changing: 'user_id' => get_the_author_meta('ID'),

i changed it as: 'author_email' => $curauth->user_email,