So now having installed WordPress, it turns out that it is infinitely customisable! Oh joy… more to learn about!
The task was to be able to build a single category RSS feed that people can subscribe to if they so chose, rather than have to subscribe to all categories, or all comments. In the theme I am using the sidebar holds the category list and it was here that the code had to go.
The issue was to find the category ID and the category name and only show the link to the RSS *if* the user had opted to view all posts in a single category.
It turns out that WordPress has done most of the hard work for us, in that the functions to get the ID and name are already created. All that had to happen was to find those arguments, wrap them in an ‘If’ tag and post them to the sidebar. Once again, some gentle reading of the Woprdpress documentation got me half way there and able to manually write the code for each category… but it needed automating. And once more, Alex Blanc stepped up to the plate…
To cut a very long story short, here’s the code, entered as a list item in the sidebar.php file for the theme:
<?php if (get_query_var('cat')) { ?> <li> <a xhref="/wp-rss2.php?cat=<?php echo get_query_var('cat'); ?>"><?php echo single_cat_title(); ?> (RSS)</a> </li> <?php } ?>
This then writes the title of the category in the sidebar as an RSS link, and ensures that only that category’s posts are included in that particular feed. You can see from the code that the link is using RSS2, so you can probably amend this to be any other flavour of feed that you wish.