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的主要内容,如果未能解决你的问题,请参考以下文章

php facetwp index复选框保存为数组

php facetwp index复选框保存为数组

php facetwp index date作为排序的原始值

php facetwp index date作为排序的原始值

php facetwp index指示设置字段而不是字段的值

为啥 www.example.com/index.php/my/path/here 由 index.php 处理?