Hi Remco,
Great plugin! But is there a 'designated' way to show geo-tagged posts in a wordpress-friendly way in-a-sort-order-by-distance from a given geo-coordinate?
I am trying to manage exactly that, - any help would be greatly appreciated. I currently use not a seperate table, i want to use the
'standard' Pronamic-Fields for longitude and latitude..
Currently I try to get things done with custom SQL-Queries like that:
(where 49.0, 8.4 are my coordinates, germany)
$querystr = "
SELECT
ACOS( SIN( RADIANS( 49 ) ) * SIN( RADIANS( pm1.meta_value ) ) + COS( RADIANS( 49 ) ) * COS( RADIANS( pm1.meta_value ) ) * COS( RADIANS( pm2.meta_value ) - RADIANS( 8.4 ) ) ) *3959 AS distance,
pm1.meta_value AS lat, pm2.meta_value AS lon,
p.*
FROM wp_posts p
INNER JOIN wp_term_relationships ON ( p.id = wp_term_relationships.object_id )
INNER JOIN wp_postmeta pm1 ON p.id = pm1.post_id AND pm1.meta_key = '_pronamic_google_maps_latitude'
INNER JOIN wp_postmeta pm2 ON p.id = pm2.post_id AND pm2.meta_key = '_pronamic_google_maps_longitude'
WHERE post_type = 'post'
AND post_status = 'publish'
AND ( wp_term_relationships.term_taxonomy_id IN ( $cat ) )
ORDER BY distance ASC
LIMIT 0 , 10
";
I would like to have some help - or I am the only one who wants that? Can't believe that.. :)
It should give an example how to archive a "sort-by-distance-posts" category-blog.php (example) that follow the rules of wordpress standards, that is what I am missing here..
kind regards,
Ingo