This code excludes all posts in one specific category from displaying in on your sites search results page from using the search widget native to WordPress.
Simply add the code to the end of your child themes functions.php file.
You’ll also need to swap out the category id with your own.
If you want to exclude multiple categories, seperate the category I.D’s with a comma.
Here’s the code for logged in members: