I'm creating a website where the customer will enter their postal code and the pages (with a distance selected of 5, 10, 20 miles) will display on either a Google map or Bing map. The page results will display to the side of the map with a linkable Title and Address to visit the Page.

My thought is to add fields to the Page where the address and postal code can be entered. Then add a function on the Index that will pull the results from the Pages. The first piece is the customer will narrow their selection through Categories first. If this function would be easier to pull from Posts, I can change my route.

I actually had a dream of how this plugin could add tables to the sql but I've never made anything like this before... thoughts?

1 Answer 1


There are a lot of pieces to this puzzle.

You need to be able to convert the postcodes into a numerical data format so you can query the pages/posts with "is greater than [current location minus 5 miles] and less than [current location plus 5 miles". In two dimensions. This means storing the latitude and longitude with the page. You can automate this, so that your custom postcode field updates custom lat and long fields on save, but obviously that's some custom code.

See: How can I implement a location based (zip code) search in WordPress?

There is some stuff on there about radiuses (because something both 5 miles north and 5 miles east is actually more than 5 miles away) but if you're going to show the results on a square Google map then you may as well include what's in the corners.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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