
Definition
In WordPress, comment_text_rss() prints the comment text in a form that is safe inside an RSS feed.
It prints the text. It is used in feed templates, for example inside the description tag of a comment feed.
Syntax
It takes no arguments. Call it in the loop of a comments feed.
| Call | What it does |
|---|
comment_text_rss() | Prints the current comment text for a feed. |
get_comment_text() | Returns the raw comment text. |
comment_text() | Use this one in normal theme pages. |
Special characters are converted so that the XML stays valid.
Full declaration
Parameters
| Parameter | Description |
|---|
| None | This function has no parameters. It uses the current comment. |
Return Value
| Return Value | Description |
|---|
| void | Nothing is returned. The function prints the text. |
WordPress Examples
Three short theme examples. Each one has a sample output.
Example 1 — In a feed item
Print the comment text in a feed description.
<description><![CDATA[<?php comment_text_rss(); ?>]]></description>
<description><![CDATA[Thanks, this helped me a lot!]]></description>
How It Works
- Each comment gets one feed item.
comment_text_rss() prints the message.CDATA protects the text inside XML.
Example 2 — Whole feed item
Use it together with the author tag.
<item>
<dc:creator><![CDATA[<?php comment_author_rss(); ?>]]></dc:creator>
<description><![CDATA[<?php comment_text_rss(); ?>]]></description>
</item>
<item>
<dc:creator><![CDATA[Jane Doe]]></dc:creator>
<description><![CDATA[Thanks, this helped me a lot!]]></description>
</item>
How It Works
comment_author_rss() prints the name.comment_text_rss() prints the message.- Both run for the same comment.
Example 3 — Return value
Use get_comment_text() when you build the XML yourself.
<?php $text = get_comment_text(); ?>
<description><?php echo esc_html( $text ); ?></description>
<description>Thanks, this helped me a lot!</description>
How It Works
get_comment_text() returns the raw text.esc_html() keeps the XML valid.- Use this when you do not want
CDATA.
Frequently Asked Questions
It prints the text of the current comment in a form that is safe for RSS.
In feed templates, such as a custom comments feed.
comment_text() is for pages and keeps HTML paragraphs. The RSS version is cleaned for XML.
No. It always uses the current comment.
Use get_comment_text().
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
10 people found this page helpful