hey, i know exactly how to do what you guys want.
to limit search results to a specific category you have to include an if/then test inside TheLoop. hopefully everyone will take example from me and learn it’s better to INCLUDE CONTEXTUAL EXAMPLES! here’s mine :
** original code from search.php, using wp1.5.1 **
<?php while (have_posts()) : the_post(); ?>
<div class=”post”>
<h3 id=”post-<?php the_ID(); ?>”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h3>
<small><?php the_time(‘l, F jS, Y’) ?></small>
<div class=”entry”>
<?php the_excerpt() ?>
</div>
<p class=”postmetadata”>Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’,”,’|‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></div>
<?php endwhile; ?>
** modified code to search cat2, using wp1.5.1 **
<?php while (have_posts()) : the_post(); ?>
<?php if ( in_category(2) ) { ?> <!– check to see if this is in cat2 –>
<div class=”post”>
<h3 id=”post-<?php the_ID(); ?>”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h3>
<small><?php the_time(‘l, F jS, Y’) ?></small>
<div class=”entry”>
<?php the_excerpt() ?>
</div>
<p class=”postmetadata”>Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’,”,’|‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></div>
<?php } ?> <!– Close the if statement. –>
<?php endwhile; ?>
**end of code**
as you can see, you simply use the if/then (which i commented) to check and make sure the post being run thru the loop is inside your specified category. copy and paste the code to a text editor to look at it without word-wrap, and it’s really pretty simple.
as with any if/then modifiers, you can have more than one. just make each seperate, you can also use negative qualifiers to exlude categories. the syntax is shown on the codex.
good luck!