Skip to content

Instantly share code, notes, and snippets.

@3200creative
Last active December 25, 2015 01:39
Show Gist options
  • Save 3200creative/6896267 to your computer and use it in GitHub Desktop.
Save 3200creative/6896267 to your computer and use it in GitHub Desktop.
Exclude particular category from posts archive - WordPress
//* Hide Category from Home Archive
add_action( 'pre_get_posts', 'be_exclude_category_from_blog' );
function be_exclude_category_from_blog( $query ) {
if( $query->is_main_query() && $query->is_home() ) {
$query->set( 'cat', '-4' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment