martes, 1 de diciembre de 2009

Exclude categories from Wordpress RSS

The Haycroft Media website uses a category for the flashy portfolio on the home page, which we want to hide from the Wordpress RSS feed

There are various options for doing this all detailed in a nice simple tutorial at Web-Kreation.com. We opted for option 2: Exclude categories in your template’s functions.php file, which simply involved the addition of a few lines of code to the functions.php file (just change the category id to that of the one you wish to omit):


function myFeedExcluder($query) {
if ($query is_feed) {
$query set('cat','-12');
}
return $query;
}
add_filter('pre_get_posts','myFeedExcluder');

No hay comentarios:

Publicar un comentario