Wordpress Technology

Wordpress Tips, Tutorials, Hacks

Exclude Categories From RSS

If for some reasons we have to exclude one or several categories from RSS, it can be done this way. Insert into functions.php next code.

function myFilter($query) {
	if ($query->is_feed) {
		$query->set('cat','-5');
	}
	return $query;
}
add_filter('pre_get_posts','myFilter');

In this case 5 means excluded category id.

If we need to expel more than one categories, their id must be inserted in the second parameter of the set() method.

$query->set('cat','-5,-7,-8');


Both comments and pings are currently closed.

© 2009 | Made by Vancouver Web Design | Internet Marketing