How to prevent posts from a particular category to be displayed in WordPress loop

Paste the code below into your functions.php file. Don't forget to update the code with the category ID you want to exclude (on line 4).