WordPress the_category_rss() Function

Beginner
6 min read
Updated: Nov 2026
3 examples
Prints feed XML

Definition

In WordPress, the_category_rss() prints the categories of a post as XML for a feed. Each category becomes one <category> tag.

You only use it when you write your own feed template. On normal pages use the_category().

Syntax

A few ways to call the_category_rss().

WordPress
<item>
  <title><?php the_title_rss(); ?></title>
  <?php the_category_rss(); ?>
</item>
CallWhat it does
the_category_rss()Print category tags in the default feed type.
the_category_rss( 'rdf' )Print them as dc:subject tags for an RDF feed.
the_category_rss( 'atom' )Print them in Atom feed format.
get_the_category_rss()Return the same text as a string.

It prints one XML tag for each category and tag of the post. It also includes post tags.

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

Parameters

ParameterDescription
$typestring. The feed type: rss, atom, or rdf. Default is the default feed type of the site.

Return Value

Return ValueDescription
voidNothing is returned. The XML tags are printed.

WordPress Examples

Three short examples. Each one shows the code and what it prints.

Example 1 — Categories inside a feed item

Use it inside an item of a custom RSS feed.

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

How It Works

  1. the_title_rss() prints the title for the feed.
  2. the_category_rss() prints one category tag for each category.
  3. Names are wrapped in CDATA.

Example 2 — RDF feed type

Pass rdf for an RDF feed.

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

How It Works

  1. The type rdf changes the tag name.
  2. RDF feeds use dc:subject for categories.
  3. The values are the same.

Example 3 — Return the XML

Use get_the_category_rss() to store the text.

WordPress
<?php
$cats = get_the_category_rss( 'rss' );
echo $cats;

How It Works

  1. get_the_category_rss() returns the same XML as a string.
  2. You can check or change it before you print.
  3. Here we just print it.

Frequently Asked Questions

It prints the categories of a post as XML tags for an RSS feed.
Only in feed templates, inside an item.
Yes. It prints both categories and post tags.
Pass rss, atom, or rdf as the first argument.
Use the_category().

Browse all post functions

Open the functions index for simple guides with examples and FAQs.

Post Functions Index →

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.

7 people found this page helpful