WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 Apr 2 '13 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 Apr 2 '13 at 17:29

Could 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.org/extend/plugins/geo-mashup/ and try https://code.google.com/p/wordpress-geo-mashup/wiki/TagReference for the references.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.