Using WordPress ‘comment_author_rss()’ PHP function

The comment_author_rss() WordPress PHP function displays the name of the current comment author in the RSS feed.

Usage

Here’s a simple example of using comment_author_rss():

// In your RSS template file
echo 'This comment was posted by ';
comment_author_rss();

In this example, if the current comment was posted by “John Doe”, the output would be “This comment was posted by John Doe”.

Parameters

The comment_author_rss() function takes no parameters.

More information

See WordPress Developer Resources: comment_author_rss()

This function is included in WordPress from version 2.0.0.

Examples

Display Comment Author Name in RSS feed

echo 'Comment by: ';
comment_author_rss();

This code will display “Comment by: [Author Name]” in the RSS feed, where [Author Name] is the name of the person who posted the comment.

Add Prefix to Comment Author Name in RSS feed

echo 'Posted by: ';
comment_author_rss();

This code will display “Posted by: [Author Name]”, with the author’s name following “Posted by: “.

Add Suffix to Comment Author Name in RSS feed

comment_author_rss();
echo ' on this post.';

This code will display “[Author Name] on this post”, where [Author Name] is the name of the person who posted the comment.

Display Comment Author Name with Custom Separator in RSS feed

echo '|| ';
comment_author_rss();
echo ' ||';

This code will display “|| [Author Name] ||” in the RSS feed, with “||” as the separator.

Display Comment Author Name in Sentence in RSS feed

echo 'This comment was made by ';
comment_author_rss();
echo '.';

This code will display “This comment was made by [Author Name].”, adding a period at the end.