4

enter image description here

I was really suprised when I couldn't find WP functionality to display the person's name who was replied to.. Any way around this problem? How do I get the name of parent comment's author?

4

In your comment callback, you could get that info with the help of the comment_parent property of the current $comment object.

We can then use the comment_author() function to display the comment author's name:

// Display the parent comment author's name:
if( $comment->comment_parent )
    comment_author( $comment->comment_parent );

and the comment_author_link() function to display the comment author's link:

// Display the parent comment author's link:
if( $comment->comment_parent )
    comment_author_link( $comment->comment_parent );
  • This should give the name of the author, one level above, so if someone replies to Rick, then it should output Rick @TwerkingN00b – birgire Feb 25 '16 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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