dogankirnaz
dogankirnaz

Reputation: 27

Listing comments by author else not working

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.";}

Upvotes: 0

Views: 62

Answers (2)

dogankirnaz
dogankirnaz

Reputation: 27

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

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

Upvotes: 0

Raf
Raf

Reputation: 352

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

Upvotes: 0

Related Questions