Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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,

share|improve this question
2  
Custom Fields/Post Meta Data is what you're looking for. You could then query by meta_key/meta_value. –  kaiser Feb 28 '12 at 8:52
1  
Just like what kaiser said. Maybe 2 meta value, 'latitude' & 'longitude', so you can sort it using '<' or '>' operator –  ifdion Feb 28 '12 at 16:47
    
I already have two custom field containing latitude and longitude. but how do i make use of it ? –  Hassan Z Feb 29 '12 at 5:14
    
Use the query_posts() function with meta_key & order parameters –  Rilwis Feb 29 '12 at 10:29
    
Any progress? Tried any geo location plugins? –  kaiser Apr 19 '12 at 3:16

2 Answers 2

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.

share|improve this answer
    
sure, I will look into it. Looks good tho. –  Hassan Z May 22 '12 at 2:30
    
thank you. i would love to get any feedback if you get to use it. it is a new release so i'd like to know if anything goes wrong. –  Eyal May 22 '12 at 6:14

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.

share|improve this answer

Your Answer

 
discard

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.