Save coordinates as customfield “coordinaten” with format [latitude],[longitude]. These terms wil be split so facetwp can pass the location to Google.
add_filter('facetwp_index_row', function ($params, $class) {
if ('proximity' == $params['facet_name']) {
if (!empty($params['facet_value'])) {
$related_post_id = $params['term_id'];
$coordinaten = get_term_meta($related_post_id, 'coordinaten', true);
$lat_lng = explode(',', $coordinaten);
$params['facet_value'] = $lat_lng[0];
$params['facet_display_value'] = $lat_lng[1];
}
}
return $params;
}, 10, 2);

Eén reactie
Can you give some screenshots of things please? I can’t get the distance to show it just says 0 as a distance but I’ve set the GPS data.