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?
1 Answer
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 );