Last active
December 3, 2018 23:37
-
-
Save mgibbs189/35e93f160bb49b874abbfc60ac353bc5 to your computer and use it in GitHub Desktop.
FacetWP - index lat/long from the "Geo My WP" plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment