FacetWP – index latitude and longitude

mgibbs189

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

function listable_fix_geolocation_indexing( $params, $class ) {
if ( ‘cf/geolocation_lat’ == $params[‘facet_source’] ) {
$lat = $params[‘facet_value’];
if ( ! empty( $lat ) ) {
$lat = get_post( $params[ ‘post_id’ ] )->geolocation_lat;
$lng = get_post( $params[ ‘post_id’ ] )->geolocation_long;
//save the latitude in the facet value
$params[‘facet_value’] = $lat;
//save the longitude in the facet display value
$params[‘facet_display_value’] = $lng;
}
}
return $params;
}
add_filter( ‘facetwp_index_row’, ‘listable_fix_geolocation_indexing’, 10, 2 );
{{/gist}}