WordPress comment_text_rss() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

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.

WordPress
comment_text_rss();
CallWhat 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
WordPress
comment_text_rss(): void

Parameters

ParameterDescription
NoneThis function has no parameters. It uses the current comment.

Return Value

Return ValueDescription
voidNothing 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.

WordPress
<description><![CDATA[<?php comment_text_rss(); ?>]]></description>

How It Works

  1. Each comment gets one feed item.
  2. comment_text_rss() prints the message.
  3. CDATA protects the text inside XML.

Example 2 — Whole feed item

Use it together with the author tag.

WordPress
<item>
  <dc:creator><![CDATA[<?php comment_author_rss(); ?>]]></dc:creator>
  <description><![CDATA[<?php comment_text_rss(); ?>]]></description>
</item>

How It Works

  1. comment_author_rss() prints the name.
  2. comment_text_rss() prints the message.
  3. Both run for the same comment.

Example 3 — Return value

Use get_comment_text() when you build the XML yourself.

WordPress
<?php $text = get_comment_text(); ?>
<description><?php echo esc_html( $text ); ?></description>

How It Works

  1. get_comment_text() returns the raw text.
  2. esc_html() keeps the XML valid.
  3. 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().

Next: comment_time()

Print the time when the current comment was posted.

comment_time() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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