php facetwp index geo my wordpress latitude / longitute
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php facetwp index geo my wordpress latitude / longitute相关的知识,希望对你有一定的参考价值。
<?php
/**
* select post type in the map or proximity facet as the datasource, this is just a placeholder
* looks up lat/lng from GEO my WordPress plugin tables
* do a full re-index in facetwp's settings to update the indexed values after adding code
*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'my_map_facet' == $params['facet_name'] ) { // be sure to change this to the name of your facet
global $wpdb;
$sql = $wpdb->prepare( "SELECT latitude, longitude FROM {$wpdb->prefix}gmw_locations WHERE object_id = %d AND object_type = 'post' LIMIT 1", $params['post_id'] );
$result = $wpdb->get_row( $sql );
if ( null !== $result ) {
$params['facet_value'] = $result->latitude;
$params['facet_display_value'] = $result->longitude;
}
else {
return false;
}
}
return $params;
}, 10, 2 );
以上是关于php facetwp index geo my wordpress latitude / longitute的主要内容,如果未能解决你的问题,请参考以下文章