Pull latitude / longitude from a custom table

mgibbs189

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

add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘YOUR_FACET_NAME_HERE’ == $params[‘facet_name’] ) {
global $wpdb;

$sql = $wpdb->prepare( “SELECT lat, lng FROM {$wpdb->prefix}cp_ad_geocodes WHERE post_id = %d LIMIT 1”, $params[‘post_id’] );
$result = $wpdb->get_row( $sql );

if ( null !== $result ) {
$params[‘facet_value’] = $result->lat;
$params[‘facet_display_value’] = $result->lng;
}
else {
return false;
}
}
return $params;
}, 10, 2 );

{{/gist}}