views:

485

answers:

1

After reading the Wordpress documentation, I realized you can remove posts from the index using filters inside "The Loop", e.g.:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<!-- The following tests if the current post is in category 3. -->
<?php if (in_category('3')) continue; ?>

<!-- display normal post -->
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>

What I'm wondering is if there is a filter/hook to filter posts in have_posts() without modifying the template. So far, I found options to change the results, but not remove results form the result set.

+1  A: 

So you want to remove it from displaying but still have it 'there' incase you decide to show it later? Not really clear on what you want to do.

As one example, in the past I've used Query Posts to keep categories off of my homepage: http://codex.wordpress.org/Template%5FTags/query%5Fposts#Exclude%5FCategories%5FFrom%5FYour%5FHome%5FPage

Adam
Got to agree with Adam here--use one of the category arguments (they can be found in that article Adam linked) with query_posts to filter your categories.
Michael