The get_comment_author_rss() WordPress PHP function retrieves the current comment author for use in the feeds.
Usage
echo get_comment_author_rss();
Input: A comment on a post.
Output: The comment author’s name in an RSS feed.
Parameters
- None
More information
See WordPress Developer Resources: get_comment_author_rss()
Examples
Display the comment author’s name in an RSS feed
This code displays the comment author’s name in an RSS feed for each comment on a post.
// Inside the comments loop echo '<author>' . get_comment_author_rss() . '</author>';
Customize comment author’s name display in an RSS feed
This code customizes the comment author’s name display in an RSS feed by adding a prefix “By: ” before the name.
// Inside the comments loop echo '<author>By: ' . get_comment_author_rss() . '</author>';
Adding comment author’s name to an RSS item’s title
This code adds the comment author’s name to an RSS item’s title.
// Inside the comments loop echo '<title>Comment by ' . get_comment_author_rss() . ': ' . get_comment_text() . '</title>';
Display comment author’s name and URL in an RSS feed
This code displays the comment author’s name and their website URL in an RSS feed.
// Inside the comments loop echo '<author>'; echo get_comment_author_rss() . ' (' . get_comment_author_url_rss() . ')'; echo '</author>';
Using the comment author’s name in a custom RSS feed
This code creates a custom RSS feed for comments, displaying the author’s name, date, and comment content.
// Inside the comments loop echo '<item>'; echo ' <title>Comment by ' . get_comment_author_rss() . '</title>'; echo ' <pubDate>' . get_comment_date( 'r' ) . '</pubDate>'; echo ' <description><![CDATA[' . get_comment_text() . ']]></description>'; echo '</item>';