Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, thethumbnail.meta_value AS thumbnail_id,
- thelat.meta_value AS latitude,thelong.meta_value AS longitude,
- ASIN ( SQRT (POWER(SIN(($lat - thelat.meta_value)*pi()/180 / 2),2) + COS($lat * pi()/180) * COS(thelat.meta_value *pi()/180) * POWER(SIN(($long - thelong.meta_value) *pi()/180 / 2), 2) ) ) AS distance
- FROM $wpdb->posts
- LEFT JOIN $wpdb->postmeta AS thelong ON ($wpdb->posts.ID = thelong.post_id)
- LEFT JOIN $wpdb->postmeta AS thelat ON ($wpdb->posts.ID = thelat.post_id)
- LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
- LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
- LEFT JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
- LEFT JOIN $wpdb->postmeta AS thethumbnail ON ($wpdb->posts.ID = thethumbnail.post_id)
- WHERE $wpdb->posts.ID NOT IN ($post->ID)
- AND thelat.meta_key = 'wpcf-latitude'
- AND thelong.meta_key = 'wpcf-longitude'
- AND $wpdb->posts.post_status = 'publish'
- AND $wpdb->posts.post_type = 'places'
- AND $wpdb->term_taxonomy.taxonomy = 'countries'
- AND thethumbnail.meta_key = '_thumbnail_id'
- ORDER BY distance
- LIMIT 12
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement