Here’s a trick I learned tonight.
/* this code excludes all of the 'international (id = 20) posts AND CHILDREN */
function exclude_category($query) {
$child_cats = (array) get_term_children('20', 'category');
if ( $query->is_home ) {
$query->set('category__not_in',array_merge(array('20'), $child_cats));
return $query;
}
}
add_filter('pre_get_posts', 'exclude_category');
the $query->set is used just like query_posts
who knew?
Advertisement