wordpress's default Recent Comments widget is showing the user's email address instead of their display/first name..

get_comment_author() just changes the email address to 'anonymous'....

What do I change exactly to make it show the commenter's name instead?

$output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
                '' . get_comment_author_link( $comment ) . '',
                '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . 
get_the_title( $comment->comment_post_ID ) . '</a>'                 

2 Answers 2


Simply use get_comment_author_email. See here for more information.

  • No that gives me the email address. I'm trying to get the commenter's name to display. Nothing I try works Oct 15, 2018 at 15:50
  • What if they don't fill in a name? That's probably why you get anonymous. You have to set wordpress to not accept anonymous comments then.
    – Pim
    Oct 15, 2018 at 16:04
  • im still using myself to test, and my first name and/or display name isn't showing up. Just anonymous.... Oct 15, 2018 at 16:28

Ok guys, sorry I figured this out. I'm still learning WP's codex...

the following worked:

get_comment_author($comment), but it was showing old usernames after I had changed the users so that they would have user names... my bad :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.