WordPress the_category_rss() Function

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

Definition

In WordPress, the_category_rss() prints the categories of the current post in the format an RSS or Atom feed needs.

You use it inside a feed template, not in a normal theme page. It prints XML tags. It does not return them.

Syntax

Call it inside a feed item. Pass a type only if you need a special feed format.

WordPress
the_category_rss();
the_category_rss( 'atom' );
the_category_rss( 'rdf' );
CallWhat it does
the_category_rss()Prints the categories in the default feed format.
the_category_rss( 'atom' )Prints the categories as Atom tags.
the_category_rss( 'rdf' )Prints the categories as RDF tags.

Use get_the_category_rss() if you want the XML string instead of printing it.

Full declaration
WordPress
the_category_rss( string $type = null ): void

Parameters

ParameterDescription
$typeOptional. The feed type: rss, atom, or rdf. Default is the type of the current feed.

Return Value

Return ValueDescription
voidNothing is returned. The function prints XML for each category.

WordPress Examples

Three short theme examples. Each one has a sample output.

Example 1 — RSS item

Add the categories to an RSS item.

WordPress
<item>
  <title><?php the_title_rss(); ?></title>
  <?php the_category_rss(); ?>
</item>

How It Works

  1. the_title_rss() prints the post title for the feed.
  2. the_category_rss() prints one category tag for each category.
  3. The names are wrapped in CDATA so special characters stay safe.

Example 2 — Atom entry

Ask for the Atom format.

WordPress
<entry>
  <?php the_category_rss( 'atom' ); ?>
</entry>

How It Works

  1. 'atom' selects the Atom format.
  2. Each category becomes a category tag with a term attribute.
  3. Use this inside an Atom feed template.

Example 3 — RDF item

Ask for the RDF format.

WordPress
<item>
  <?php the_category_rss( 'rdf' ); ?>
</item>

How It Works

  1. 'rdf' selects the RDF format.
  2. Each category becomes a dc:subject tag.
  3. You rarely need this format, but it is good to know it exists.

Frequently Asked Questions

It prints the categories of the current post as XML tags for an RSS, Atom, or RDF feed.
Only inside a feed template, for example a custom feed. Normal theme pages should use the_category().
the_category_rss() prints the XML. get_the_category_rss() returns it as a string.
No. The function already escapes the category names for feed XML.
It picks the feed format: rss, atom, or rdf. If you leave it out, WordPress uses the format of the current feed.

Next: the_tags()

Print the tags of the current post as links with optional text around them.

the_tags() 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.

9 people found this page helpful