Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've searched and found posts that have asked and answered how to merge different categories into an RSS feed. What I need to know is how to exclude specific categories from the RSS feed?

Specifically, I use WP to post blog articles and to post portfolio items onto my site. I want to exclude the portfolio category from appearing in the RSS feed, making only blog posts available.

share|improve this question
    
Thanks for the quick responses –  Ray Mitchell Mar 6 '11 at 16:53

3 Answers 3

up vote 0 down vote accepted

It's been broken since 3.1, see:
http://core.trac.wordpress.org/ticket/16622
and also
http://wordpress.org/support/topic/wp-31-breaks-rss-customization-via-exclude_category NOTE: Otto's suggested fix in that thread doesn't work for me.

Ticket suggests patch will go in for 3.1.1 and i can confirm that currently filters on pre_get_posts or parse_query fail for feeds(unfortunately).

share|improve this answer
    
@t3los - in the thread you listed there is a plugin that may do the trick for now (wordpress.org/extend/plugins/ultimate-category-excluder). I'm planning on giving it a try. –  Ray Mitchell Mar 6 '11 at 16:52
function wpsites_exclude_category_rss_feed($query) {
 if ($query->is_feed) {
   $query->set('cat','-007,-008');
 }
return $query;
}
add_filter('pre_get_posts','wpsites_exclude_category_rss_feed');

Either of these snippets in your functions file will work using pre_get_posts

function wpsites_exclude_category_rss_feed($query) {
if ( $query->is_feed) {
    $query-> set('category__not_in',array(007));
    }
return $query;
}
add_filter('pre_get_posts','wpsites_exclude_category_rss_feed');
share|improve this answer

Not too confident to get hooks right from memory... I think hooking into pre_get_posts and setting category__not_in to what you want to skip on is_feed() conditional should work.

But might require playing with different hooks earlier/later, querying internals are confusing around there.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.