SHOW:
|
|
- or go back to the newest paste.
| 1 | - | SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, thethumbnail.meta_value AS thumbnail_id, |
| 1 | + | SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, getthumbinfo.meta_value AS metainfo, |
| 2 | thelat.meta_value AS latitude,thelong.meta_value AS longitude, | |
| 3 | 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 | |
| 4 | FROM $wpdb->posts | |
| 5 | LEFT JOIN $wpdb->postmeta AS thelong ON ($wpdb->posts.ID = thelong.post_id) | |
| 6 | LEFT JOIN $wpdb->postmeta AS thelat ON ($wpdb->posts.ID = thelat.post_id) | |
| 7 | LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) | |
| 8 | LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) | |
| 9 | LEFT JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) | |
| 10 | - | LEFT JOIN $wpdb->postmeta AS thethumbnail ON ($wpdb->posts.ID = thethumbnail.post_id) |
| 10 | + | LEFT JOIN $wpdb->postmeta AS getthumbid ON ($wpdb->posts.ID = getthumbid.post_id) |
| 11 | LEFT JOIN $wpdb->postmeta AS getthumbinfo ON (getthumbid.meta_value = getthumbinfo.post_id) | |
| 12 | WHERE $wpdb->posts.ID NOT IN ($post->ID) | |
| 13 | AND thelat.meta_key = 'wpcf-latitude' | |
| 14 | AND thelong.meta_key = 'wpcf-longitude' | |
| 15 | AND $wpdb->posts.post_status = 'publish' | |
| 16 | AND $wpdb->posts.post_type = 'places' | |
| 17 | - | AND thethumbnail.meta_key = '_thumbnail_id' |
| 17 | + | |
| 18 | AND getthumbid.meta_key = '_thumbnail_id' | |
| 19 | AND getthumbinfo.meta_key = '_wp_attachment_metadata' | |
| 20 | ORDER BY distance | |
| 21 | LIMIT 12 |