Simple line of code to exclude category from WordPress loop
If you wish to exclude a certain category from the WordPress loop so that posts do not show on a particular page you can do so with the following line of code:
< ?php query_posts('cat=-3'); ?>< /blockquote>
For the purpose of this example, the above code has a ‘space’ separating the < ? at the start of the code and 'space' separating the < /blogquote>. You will need to remove the spaces in order to use the code in your template / theme.
Note: -3 is the category you are excluding. You can replace this with the ID of your own category.
Example of where to place the code:
Code should be placed directly above the start of the loop. In this example i am using the index.php template page.
< ?php query_posts('cat=-3'); ? >
< ?php if (have_posts()) : ? >
< ?php while (have_posts()) : the_post(); ? >