Created
June 26, 2012 23:40
-
-
Save mattwiebe/3000188 to your computer and use it in GitHub Desktop.
exclude category from home
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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