By default the wordpress search accept only one parameter: ?s=your-term
For add more functionality in a Wordpress search, you must create a new search configuration, that accept your extra parameter.
For Example.
If you want to search inside a specific category, you have to create a custom function like this:
// advanced search functionality
function advanced_search_query($query) {
if($query->is_search()) {
// your extra param is: in_category // &in_category=sample-category
if (isset($_GET['in_category'])) {
$query->set('category_name', $_GET['in_category']);
}
return $query;
}
}
add_action('pre_get_posts', 'advanced_search_query', 1000);
By the way, this not ending here.
This a custom search inside normal Wordpress category, but this is the same logic for create a custom search for Woocommerce.
Simple you have to add more query variable in the wordpress WP_Query, like this:
// advanced search functionality
function advanced_search_query($query) {
if($query->is_search()) {
if (isset($_GET['in_category'])) {
$query->set('tax_query', array(array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array($_GET['in_category']) )
));
}
return $query;
}
}
add_action('pre_get_posts', 'advanced_search_query', 1000);
Now, you can use a sintax like this: http://nsr.przedprojekt.com/wp/?s=kross&in_category=rowery