Last active
August 15, 2017 00:07
-
-
Save braddalton/5021613 to your computer and use it in GitHub Desktop.
Exclude posts from one or more categories from displaying on your home page http://wpsites.net/web-design/exclude-category-posts-page/
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
add_action( 'pre_get_posts', 'exclude_category_posts' ); | |
/** | |
* @author Brad Dalton - WP Sites | |
* @example http://wpsites.net/web-design/exclude-category-posts-page/ | |
*/ | |
function exclude_category_posts( $query ) { | |
if( $query->is_main_query() && $query->is_home() ) { | |
$query->set( 'cat', array( -27, -30 ) ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment