If customer needs to search all locations then he should not select anything in the Location field when doing search.
But first city in list goes as default for search…
add_filter( 'adverts_form_load', 'location_to_dropdown' );
function location_to_dropdown( $form ) {
if( $form['name'] != 'search' ) {
return $form;
}
foreach( $form["field"] as $key => $field ) {
if( $field["name"] == "location" ) {
$field["type"] = "adverts_field_select";
$field["options"] = array(
array("value" => "Киев", "text" => "Киев", "depth" => 0),
array("value" => "Александрия", "text" => "Александрия", "depth" => 0),
array("value" => "Бахмут (быв. Артёмовск)", "text" => "Бахмут (быв. Артёмовск)", "depth" => 0),
);
$form["field"][$key] = $field;
}
}
return $form;
}
After
$field["type"] = "adverts_field_select";
add
$field["empty_option"] = true;
$field["empty_option_text"] = "All Locations";
It works fine with keyword and price search, thanks. But when choose some category to search ads in, it shows ‘Nothing here’. ‘All locations’ and ‘Category’ search functions conflict with each other(((
What is your website URL?
Hi Greg. Do you have any idea why ‘All locations’ and ‘Category’ search conflict? This function is so crucial
I am not sure, i will check it later today on my site and update this thread.
It seems to me that the search by category does not work on your site at all, regardless of settings in any other field.
I assume you are using this https://github.com/simpliko/wpadverts-snippets/blob/master/search-by-category/search-by-category.php code snippet to implement search by category? If so then replace in this file all occurances of “advert_category” with for example “ad_category” (except line 62) and try searching again.
IT DOES WORK! THANK YOU SO MUCH! I’ve already reviewed and rated your plugin as 5 stars. Your support is awesome, that’s so rare.