Always include default stores in result list
-
Hello!
Is it possible to set a number of default stores that are always included in the result list?
I have tried doing this by sql, and got as far as the query below, but it simply returns zero results. (As a curiosa, the query works perfectly when run with sample lat-lng values in phpmyadmin, just not in the plugin)
SELECT lat, lng, ID, distance FROM ( SELECT post_lat.meta_value AS lat, post_lng.meta_value AS lng, posts.ID, ( %d * acos( cos( radians( %s ) ) * cos( radians( post_lat.meta_value ) ) * cos( radians( post_lng.meta_value ) - radians( %s ) ) + sin( radians( %s ) ) * sin( radians( post_lat.meta_value ) ) ) ) AS distance FROM $wpdb->posts AS posts INNER JOIN $wpdb->postmeta AS post_lat ON post_lat.post_id = posts.ID AND post_lat.meta_key = 'wpsl_lat' INNER JOIN $wpdb->postmeta AS post_lng ON post_lng.post_id = posts.ID AND post_lng.meta_key = 'wpsl_lng' WHERE posts.post_type = 'wpsl_stores' AND posts.post_status = 'publish' GROUP BY posts.ID, post_lat.meta_value, post_lng.meta_value $sql_sort) UNION SELECT lat, lng, ID, distance FROM ( SELECT post_lat.meta_value AS lat, post_lng.meta_value AS lng, posts.ID, ( %d * acos( cos( radians( %s ) ) * cos( radians( post_lat.meta_value ) ) * cos( radians( post_lng.meta_value ) - radians( %s ) ) + sin( radians( %s ) ) * sin( radians( post_lat.meta_value ) ) ) ) AS distance FROM $wpdb->posts AS posts INNER JOIN $wpdb->postmeta AS post_lat ON post_lat.post_id = posts.ID AND post_lat.meta_key = 'wpsl_lat' INNER JOIN $wpdb->postmeta AS post_lng ON post_lng.post_id = posts.ID AND post_lng.meta_key = 'wpsl_lng' WHERE posts.post_type = 'wpsl_stores' AND posts.post_status = 'publish' AND (posts.ID = '1706' OR posts.ID = '2835') GROUP BY posts.ID, post_lat.meta_value, post_lng.meta_value)Regards,
Susanna
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Always include default stores in result list’ is closed to new replies.