FacetWP – index latitude / longitude of related location

mgibbs189

{{gist file=”test.php” lang=”php”}}
<?php

// Add to functions.php, then re-index

function index_latlng( $params, $class ) {
if ( ’employee_geocode’ == $params[‘facet_name’] ) {
foreach ( (array) $params[‘facet_value’] as $post ) {
$params[‘facet_value’] = get_field( ‘latitude’, $post->ID );
$params[‘facet_display_value’] = get_field( ‘longitude’, $post->ID );
}
}
return $params;
}
add_filter( ‘facetwp_index_row’, ‘index_latlng’, 10, 2 );
{{/gist}}