It was pretty easy to enable RSS feeds for categories in WordPress, but I noticed today that it didn’t work for subcategories. So I took a closer look at the code and found out where the problem is. In wp-includes/template-functions-category.php
is a recursive call to list_cats()
to display subcategories. For some reason the recursive call to list_cats()
doesn’t pass in the last two arguments; $feed
and $feed_image
provided to wp_list_cats()
in index.php
. So here is the fix, first, find the line that in wp-includes/template-functions-category.php
that something like this (should be around line 366):
if ($children) $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $children, $category->cat_ID, $categories, 1);
Then simply add $feed
and $feed_image
to the end of the argument list so that it looks like this:
if ($children) $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $children, $category->cat_ID, $categories, 1, $feed, $feed_image);
That should do the trick. Please note that is based on my install of WordPress 1.2 Beta, I have no info on any other versions. Hmmmm, now I’m wondering how to add an ATOM feed link next the RSS feed link in the category listing.
Categories