FacetWP – index lat/long from the “Geo My WP” plugin

mgibbs189

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

// Add the following into the Custom Hooks plugin
add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘geo’ == $params[‘facet_name’] ) {
global $wpdb;
$post_id = (int) $params[‘post_id’];
$coords = $wpdb->get_row( “SELECT `lat`, `long` FROM {$wpdb->prefix}places_locator WHERE post_id = ‘$post_id’ LIMIT 1″ );
$params[‘facet_value’] = ( null !== $coords ) ? $coords->lat : ”;
$params[‘facet_display_value’] = ( null !== $coords ) ? $coords->long : ”;
}
return $params;
}, 10, 2 );

{{/gist}}