
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.
the_category_rss();
the_category_rss( 'atom' );
the_category_rss( 'rdf' );
| Call | What 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
the_category_rss( string $type = null ): void
Parameters
| Parameter | Description |
|---|
$type | Optional. The feed type: rss, atom, or rdf. Default is the type of the current feed. |
Return Value
| Return Value | Description |
|---|
| void | Nothing is returned. The function prints XML for each category. |
WordPress Examples
Three short theme examples. Each one has a sample output.
Example 2 — Atom entry
Ask for the Atom format.
<entry>
<?php the_category_rss( 'atom' ); ?>
</entry>
<entry>
<category scheme="https://example.com" term="News" />
<category scheme="https://example.com" term="Tips" />
</entry>
How It Works
'atom' selects the Atom format.- Each category becomes a
category tag with a term attribute. - Use this inside an Atom feed template.
Example 3 — RDF item
Ask for the RDF format.
<item>
<?php the_category_rss( 'rdf' ); ?>
</item>
<item>
<dc:subject><![CDATA[News]]></dc:subject>
<dc:subject><![CDATA[Tips]]></dc:subject>
</item>
How It Works
'rdf' selects the RDF format.- Each category becomes a
dc:subject tag. - 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
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.
9 people found this page helpful