Featured Posts

Austria Woothemes TripAustria Woothemes Trip So...I haven't posted for a while, but here I am in the snow in Austria on holiday with the Woothemes crew! Check out more of our adventures at the Woo on the Slopes site....

Readmore

How to Domain Map with WordPress MuHow to Domain Map with WordPress Mu So recently I had to implement 2 sets of sites using WordPress Mu (multi-user) and one of the requirements (for both sites) was to be able to domain map the sub-sites, much...

Readmore

Filter your WordPress RSS FeedFilter 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....

Readmore

It's Official - Woothemes!It's Official - Woothemes! Well, I have some pretty serious and exciting news to share...I have decided to take up a position at Woothemes! This is a fantastic opportunity and am really grateful to...

Readmore

WordPress JQuery AccordionWordPress JQuery Accordion So I've been tinkering with JQuery this weekend and have built a function for WordPress to display a JQuery accordion of a certain number of posts from a certain category...

Readmore

Jeffikus Rss

Filter your WordPress RSS Feed

Posted on : 02-11-2009 | By : jeffikus | In : Development, Friends, PHP, Projects, WordPress

1

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) {
$query->set('cat','-1');
}
return $query;
}
add_filter('pre_get_posts','nameOfFunction');



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!

Comments (1)

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: http://wordpress.org/support/topic/391998?replies=1

What can it be, do you have any idea?
Thanks!

Write a comment