WordPress Query custom ordering by temporary variable

Question

I have a created location proximity functionality. I have WP_query loop created for custom post type instructor. So each instructor has an address . So if some one enters the zip code it calculates the distance using google API for each post (custom post) . It successfully calculates the distance for each posts but it’s dynamic data that is not saved in the database.

I created another wp_query loop before the main one just to get the list, so i have a data like this

$result = array (
 '223' => '1.99'
 '136'  =>  '1.82',
 '166' => '1.93',
);

where key is post id and value is distance. Is there any way i can show the nearest instructor based on the data from query that made before actual one?

0
, , Latheesh V M Villa 3 years 2020-03-30T12:51:16-05:00 0 Answers 65 views 0

Leave an answer

Browse
Browse