Skip to content

Instantly share code, notes, and snippets.

@calvez
Last active July 26, 2016 09:09
Show Gist options
  • Save calvez/edf9825379f54d613903b9c6a2a64158 to your computer and use it in GitHub Desktop.
Save calvez/edf9825379f54d613903b9c6a2a64158 to your computer and use it in GitHub Desktop.
Filter posts by category on frontpage wordpress 2.9+
// =========================================
// = Filter posts by category on frontpage =
// =========================================
function exclude_category($query) {
if ( $query->is_home() ) {
$query->set('cat', '-6');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment