WordPress RSS feed exclude categories or only serve one particular category

// This will make the site feed ONLY contain category id 9.

add to wp-content/themes/your-active-theme/function.php

function myFilter($query) {
if ($query->is_feed) {
$query->set(‘cat’,’9′);
}
return $query;
}

add_filter(‘pre_get_posts’,’myFilter‘);

// To EXCLUDE categories 9 and 11:

function myFilter($query) {
if ($query->is_feed) {
$query->set(‘cat’,’-9, -11‘);
}
return $query;
}

add_filter(‘pre_get_posts’,’myFilter‘);

One Response to “WordPress RSS feed exclude categories or only serve one particular category”

  1. Wordpress affect categories search form searches – solution 2 | alexyz Says:

    […] post: http://alexyz.com/wordpress-rss-feed-exclude-categories-or-only-serve-one-particular-category/ This entry was posted in PHP, WordPress. Bookmark the permalink. ← Minute […]

Leave a Reply

You must be logged in to post a comment.