WordPress: Excluding Categories on Secondary Front Pages
Apr 12 2009
More precisely, this tutorial covers how to exclude categories on paged front pages, index.php, beyond the first default listing.
Excluding certain categories from the front page is a pretty easy task, just use the query_posts() function to remove those categories before going into the loop, like so:
<?php if ( is_home() ) {
query_posts("cat=-3");
}
while (have_posts()) : the_post(); ?>
But if the visitor tries to see the next set of posts through “Older Entries,” the same results are queried. Instead, use this:
<?php if ( is_home() ) {
query_posts("paged=$paged&cat=-3");
}
while (have_posts()) : the_post(); ?>
We can tell query_posts() which set of posts to display with the paged parameter and the $paged variable, a WordPress variable which returns the current page number (1 for the first, 2 for the second, and so on).






