Keep posts from one category, such as News or Podcast, off the main blog page while leaving them in their own archive.
add_action( 'pre_get_posts', function ( WP_Query $query ): void {
if ( is_admin() || ! $query->is_main_query() || ! $query->is_home() ) {
return;
}
$category = get_category_by_slug( 'podcast' );
if ( $category ) {
$query->set( 'category__not_in', [ $category->term_id ] );
}
} );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
Some posts don’t belong in the main blog feed, such as short announcements or podcast episodes with their own page. This snippet hides one category from the blog page while keeping it everywhere else.
The pre_get_posts action lets you change the main query before WordPress runs it. The snippet only acts on the front-end blog page (is_home()), looks up the category by its slug and tells the query to leave it out with category__not_in.
The category’s own archive, search results and feeds aren’t affected.
Open your blog page. Posts in the excluded category should be missing, but they should still appear on that category’s page.