Filter your WordPress RSS Feed

I was working on a project last week and needed to use the categories in WordPress to seperate content, but also needed to provide an RSS Feed of only one of the 2 categories. So I did a quick Google – because I figured someone else has probably done this before – and sure enough I found this :

function nameOfFunction($query) {
if ($query->is_feed) {
return $query;


Note : the -1 is the category id, I didnt try it but I suppose you could change the category parameters where it says cat to something like category_name and still get the same result.

You could also just change the is_feed to some of the other conditional tags that WordPress has for a different effect.

Thanks to Lucas for suggesting I share this!

Published by Jeff Pearce

Most know me online as Jeffikus, I made WordPress products at WooCommerce for 7 years. Then Automattic acquired us and I've been making themes there for the past 3 years! I’m a husband, and father in beautiful Cape Town!

Join the Conversation


Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: