I’m still interested in hearing how this can be accomplished using the WordPress function the_category_rss()
, but I did find another way to do this:
<?php $parentsonly = "";
// loop through categories
foreach((get_the_category()) as $category) {
// exclude child categories
if ($category->category_parent == 0) {
$parentsonly = '<category domain="' . get_category_link($category->cat_ID) . '">' . $category->name . '</category>';
}
}
echo $parentsonly; ?>
This returns each parent category in the proper RSS validated format, using <category>
and domain
for the category URL:
<category domain="http://www.yourdomain.com/category-archive/">
My Category</category>
Hope this helps someone else!