I wanna sort all post by GEO Location.Can you provide me an idea on how can I do that.
When user submit a post, should I ask for a location as a tag but at the same time I wanna have tags to work as tags. Also Categories needs to be work as category. I am not sure how can I sort them.
However, there will be address as a custom field associate to each post.
Please guide me to a way to have this done or redirect me to a plugin that works.
Regards,
Can you use a plugin? I just released not long ago http://geomywp.com it basically does what you want. If you want to do it yourself so this is how I did it:
The plugin adds address custom fields (as meta boxes) to your post type. When post is being saved the address being converted to lat/long using google API and the data being saved in a custom table. This way you create a database table for your posts with lat/long.
When a user want to search your site Using the search form he can enter any address in the input field and choose radius value from drop down menu. The address again , being converted to lat/long and using custom SQL query you can check the user’s address against each lat/long in the custom database’s table. Then you can output posts within the given radius and ordered them by the distance from the address.
If you still haven’t solved this, I wrote a plugin a couple days ago that creates metaboxes for storing location data on selected post types (you choose which types via an interface). It also provides an extended WP_Query, that does distance searches and returns posts as well as distance, location, lat, and long.
https://github.com/fyaconiello/wp-geo-posts
give it a go, let me know what you think.