Thanks to WP Stuffs for this – http://www.wpstuffs.com/exclude-posts-category-front-page-genesis/
1 2 3 4 5 6 7 8 |
/** Exclude certain category from posts on home page - http://www.wpstuffs.com/exclude-posts-category-front-page-genesis/*/ 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', '-8' ); } } |
Change the category ID according to the category you want to exclude. Keep the minus sign.
1 |
$query->set( 'cat', '-8' ); |
To add others just add a comma after each category ID as – , ‘ID’
1 |
$query->set( 'cat', '-8', '-12' ); |
Leave a Reply