Hi,
Is there anyway to exempt certain categories from being searched? I tried using query_posts() but it seemed to pulling all of those entries instead.
Thanks,
Beth
Hi,
Is there anyway to exempt certain categories from being searched? I tried using query_posts() but it seemed to pulling all of those entries instead.
Thanks,
Beth
<?php
if( is_search() ) :
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("s=$s&paged=$paged&cat=-1,-11,-101");
endif;
?>
"s=$s" is the key for this query; $s is a global variable in WordPress that holds the search phrase. Just change "cat=-1,-11,-101" to list the categories you need excluded (minus sign before each, naturally). That $paged part is explained here:
Perfect! Thank you! :)
This topic has been closed to new replies.