php - Sort an array of posts by distance -


i using google maps api wordpress project. using custom function gooogle maps in bounds , displaying information such name, address, distance, id, etc.. distance calculated $_get variable , googleapis distancematrix.

so grab id's in viewport(bounds) , use them in query using get_posts() looks this

 $locations = ( $_get['ids'] ) ? $_get['ids'] : -1;   $args = array(     'post_type' => 'location',     'posts_per_page' => -1,     'post__in' => $locations, );   $posts = get_posts($args); // etc, etc.. 

i need sort these posts(locations) distance stuck on trying figure out way so. address stored in posts post meta serialized array. possible evaluate , sort these posts before using `foreach'?


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -