Exclude categories from search query

Question

I have two categories that I want to exclude from my search results, so far without luck.

I have tried adding the following piece of code but it didn’t work.

$search_query = query_posts(array('category__in' => array(-22, -21)));

Here is my current code.

global $query_string;

$query_args = explode("&", $query_string);
$search_query = array();

foreach($query_args as $key => $string) {
    $query_split = explode("=", $string);
    $search_query[$query_split[0]] = urldecode($query_split[1]);
} // foreach

$searchq = new WP_Query($search_query);

while ($searchq->have_posts()) : $searchq->the_post();
0
Swen 2 months 0 Answers 8 views 0

Leave an answer