In order to modify the existing Loop rather than creating a new one from scratch, you need to preserve the original query and then add something to it. Listing 7-1 shows how to remove one category (with an ID of 7) from $query_string (the variable that holds the original query) by placing a minus sign before the category ID. Keep in mind that this query string assigns values to variables. It doesn't perform comparisons, so remember not to use the more familiar comparison syntax, such as cat !=7, in a query string.
In this case, you combine query_posts() with the is_home() conditional you saw in the previous chapter to make sure that the posts from category 7 are excluded only on the home page. You wouldn't want to run this on the archive for category 7!
Listing 7-1. Excluding a category from the home page
// your usual Loop can go here
Was this article helpful?