Using Distance filter you can combine only one address field.
In order to workaround this, I've created the following views and all the following views is set to return the post IDs and having same Query Filters added as per the original view:
- hidden link
Distance
Show posts within 15km radius of address/coordinates provided using toolset_maps_distance_center URL parameter.
Taxonomy filter
Select posts with taxonomy:
Active Techniques slug in one of those set by the URL parameter wpv-active-technique
eg. hidden link
AND
Treatments Specialties slug in one of those set by the URL parameter wpv-treatments-specialty
eg. hidden link
Custom field filter
Select items with field:
Gender is a string equal to URL_PARAM(wpv-wpcf-gender)
AND
Business 1 City is a string like URL_PARAM(wpv-wpcf-business-1-city)
Post search filter
Filter post content and title by a text search that will be added manually using the shortcode [wpv-filter-search-box]
For address-1:
- hidden link
For address-2:
- hidden link
For address-3:
- hidden link
Then I've added the "toolset-custom-code" code snippet to "Custom Code" section offered by Toolset:
=> hidden link
function func_update_distance_radius_from_urlparam( $view_settings, $view_id ) {
$allowed_views = array(56427,56423,56425);
if (in_array($view_id,$allowed_views)) {
if(isset($_REQUEST['toolset_maps_distance_radius']) and
$_REQUEST['toolset_maps_distance_radius']!='') {
$view_settings['map_distance_filter']['map_distance']= $_REQUEST['toolset_maps_distance_radius'];
}
}
return $view_settings;
}
add_filter( 'wpv_view_settings', 'func_update_distance_radius_from_urlparam', 5, 2 );
add_filter( 'wpv_filter_query', 'func_text_search_with_distance', 10, 3 );
function func_text_search_with_distance($query_args,$view_settings, $view_id ){
if ( $view_id == 4952 ) {
//// getting distance search results
$geo_result = array();
//$address1_result = do_shortcode('[wpv-view name="therapists-search-map-address1" cached="off"]');
//$address2_result = do_shortcode('[wpv-view name="therapists-search-map-address2" cached="off"]');
//$address3_result = do_shortcode('[wpv-view name="therapists-search-map-address3" cached="off"]');
$address1_result = get_view_query_results( 56427 );
$geo_result = array_merge($geo_result,$address1_result);
$address2_result = get_view_query_results( 56423 );
$geo_result = array_merge($geo_result,$address2_result);
$address3_result = get_view_query_results( 56425 );
$geo_result = array_merge($geo_result,$address3_result);
$final_result = array();
if(!empty($geo_result)){
foreach($geo_result as $k=>$v):
$final_result[] = $v->ID;
endforeach;
}
$query_args['post__in'] = $final_result ;
}
return $query_args;
}
Now, when I search for the address "Chelsea, QC, Canada" I can see the "Paul Phillips" is shown with the result.
- hidden link
Can you please confirm it works as expected.