Skip to content

Instantly share code, notes, and snippets.

@mattwiebe
Created June 26, 2012 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattwiebe/3000188 to your computer and use it in GitHub Desktop.
Save mattwiebe/3000188 to your computer and use it in GitHub Desktop.
exclude category from home
<?php
function mw_exclude_cat_from_home( $query ) {
// this is the category ID(s) you want to exclude.
$to_exclude = array( 3 );
if ( $query->is_main_query() && $query->is_home() ) {
$query->set( 'category__not_in', $to_exclude );
}
}
add_action( 'pre_get_posts', 'mw_exclude_cat_from_home' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment