Created
February 11, 2015 15:38
-
-
Save hirejordansmith/ac76c54e9ca10d750e0f to your computer and use it in GitHub Desktop.
Exclude Specific Categories from the WordPress Loop
This file contains 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 | |
/** Exclude Specific Categories From The WordPress Loop */ | |
add_action( 'pre_get_posts', 'hjs_exclude_categories' ); | |
function hjs_exclude_categories( $wp_query ) { | |
if( !is_admin() && is_main_query() && is_home() ) { | |
$wp_query->set( 'cat', '-5' ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment