Tribe__Events__Pro__Geo_Loc::assign_distance_to_posts( array $posts, float $lat_from, float $lng_from )
Orders a list of posts by distance to a given geo point.
Contents
Parameters
- $posts
-
(array) (Required) List of posts to order.
- $lat_from
-
(float) (Required) Latitude of the geo point.
- $lng_from
-
(float) (Required) Longitude of the geo point.
Source
File: src/Tribe/Geo_Loc.php
public function assign_distance_to_posts( &$posts, $lat_from, $lng_from ) {
// add distances
$num_posts = count( $posts );
for ( $i = 0; $i < $num_posts; $i ++ ) {
$posts[ $i ]->lat = $this->get_lat_for_event( $posts[ $i ]->ID );
$posts[ $i ]->lng = $this->get_lng_for_event( $posts[ $i ]->ID );
$posts[ $i ]->distance = $this->get_distance_between_coords( $lat_from, $lng_from, $posts[ $i ]->lat, $posts[ $i ]->lng );
}
//no return, $posts passed by ref
}