Top Menu

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!

4 Responses to Filter your WordPress RSS Feed

  1. Daniel April 26, 2010 at 1:48 am #

    Hi. I was using this little trick in my blog, but after an update to 2.9.2 it just doesn’t work anymore, giving me a blank feed.
    See this:

    What can it be, do you have any idea?

  2. Amanda February 25, 2011 at 4:36 pm #

    I had this working until last week and then … poof.

    • Amanda February 25, 2011 at 4:43 pm #

      (The update to 3.1 seems to be what killed it.)

  3. jeffikus February 26, 2011 at 1:39 pm #

    Interesting, will check this out and let you guys know how to still achieve this!

Leave a Reply

Powered by WordPress & Woo Themes

%d bloggers like this: