I’ve got a custom post type ‘locations’ and each location has a postal code.
And I have another table with all postal codes of the country and their coordinates (longitude, latitude).
Now I want to display all existing locations within a given radius around a given postal code. I do know how to calculate the distance.
Do I have to select all possible postal codes first and then execute WP_Query with the meta_key = ‘postalcode’ and the meta_value IN [My list of possible postal codes], or is there any way to directly JOIN the tables using WP_Query?
I do need WP_Query, because I want to use WordPress features like Pagination.
Read more here: WordPress: Combine external database table and WP_Query