PHP code example of franc-liuzzi / ep-geo

1. Go to this page and download the library: Download franc-liuzzi/ep-geo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

franc-liuzzi / ep-geo example snippets


new WP_Query( array(
    'ep_integrate'   => true,
    'posts_per_page' => 100,
    'post_type'      => 'post',
    'orderby'        => 'geo_distance',
    'order'          => 'asc',
    'geo_distance'   => array(
        'distance'           => '30mi',
        'geo_point.location' => array(
            'lat' => 45.5231,
            'lon' => -122.6765,
        ),
    ),
) );

/**
 * Alter geo_point location to use my_lat/my_lon.
 */
add_filter( 'ep_geo_post_sync_geo_point', function ( $geo_point, $post_args, $post_id ) {
	$geo_point['location']['lat'] = get_field( 'my_lat', $post_id );
	$geo_point['location']['lon'] = get_field( 'my_lon', $post_id );

	return $geo_point;
}, 10, 3 );