Skip to content

Instantly share code, notes, and snippets.

@ProjectKarol
Forked from mgibbs189/test.php
Created December 3, 2018 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProjectKarol/4ff727c460fa9d7dcf95664db5bde3fe to your computer and use it in GitHub Desktop.
Save ProjectKarol/4ff727c460fa9d7dcf95664db5bde3fe to your computer and use it in GitHub Desktop.
FacetWP - index lat/long from the "Geo My WP" plugin
<?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