I'm developing a website which has states as categories and posts as cities. What we are trying to do is identify each post (city) and also show nearby cities to the current city.
As of now we are simply using the category as the only filter and "nearby" is not actually nearby. (Similar to how related posts work)
We tried to use Tags (adding some hidden tags by creating fake region division) but that has become complex on the fact that a city can also be near to another city from another state.
I'm thinking of using a custom field with longitude or latitude as a matching value.
Has anyone tried this or suggest an idea to make it simpler.
I'm developing a website which has states as categories and posts as cities. What we are trying to do is identify each post (city) and also show nearby cities to the current city.
As of now we are simply using the category as the only filter and "nearby" is not actually nearby. (Similar to how related posts work)
We tried to use Tags (adding some hidden tags by creating fake region division) but that has become complex on the fact that a city can also be near to another city from another state.
I'm thinking of using a custom field with longitude or latitude as a matching value.
Has anyone tried this or suggest an idea to make it simpler.
Share Improve this question asked Apr 2, 2013 at 12:21 Naveen NaraleNaveen Narale 273 silver badges10 bronze badges 2- The key part of this is not really a WordPress question and you've hit on the answer. You will need to geolocate your cities and use math to work our what is nearby. I am sure there are services out there that can do this for you. I believe that the Google maps API can do it, but I have not tried so I may be wrong. – s_ha_dum Commented Apr 2, 2013 at 13:50
- I would take the lat & long route. I've done something similar to this before. You can then do wp_query to find nearby locations within X KM (after converting X KM to degrees of lat and long). – vancoder Commented Apr 2, 2013 at 17:29
1 Answer
Reset to default 0Could try a plugin called Geo mash up which turns Wordpress into a GeoCMS, has nearby functionality built into it and can take long and lang values or addresses from custom fields. http://wordpress/extend/plugins/geo-mashup/ and try https://code.google/p/wordpress-geo-mashup/wiki/TagReference for the references.