How to exclude posts by ID within a category/archive loop
Use pre_get_posts to exclude the categories you don’t want to display in the loop. function exclude_posts_from_specific_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-2’ ); } } add_action( ‘pre_get_posts’, ‘exclude_posts_from_specific_category’ ); Or create a new WP_Query and use the Category Parameters. $args = array( ‘category__not_in’ => 2 , ‘category__in’ => … Read more