I insert the name of parent comment's author in child comment
if( $comment->comment_parent )
comment_author( $comment->comment_parent );
How to insert a comma to this construction in function.php?
Example,
if( $comment->comment_parent )
comment_author( $comment->comment_parent ) . ', ';
do not work.
Thanks
I insert the name of parent comment's author in child comment
if( $comment->comment_parent )
comment_author( $comment->comment_parent );
How to insert a comma to this construction in function.php?
Example,
if( $comment->comment_parent )
comment_author( $comment->comment_parent ) . ', ';
do not work.
Thanks
Share Improve this question asked Mar 9, 2019 at 20:08 Андрей СахаровАндрей Сахаров 132 bronze badges1 Answer
Reset to default 1comment_author
prints the author. It doesn’t return anything.
So if you do this:
if ( $comment->comment_parent )
comment_author( $comment->comment_parent ) . ', ';
Then, what it really does is:
- check if comment has parent and if so:
- print its author
- get the result of function
comment_author
(which is empty) and concatenate it with string containing ', ' - don’t do anything with that string
And what you want is this:
if ( $comment->comment_parent ) {
comment_author( $comment->comment_parent );
echo ', ';
}