Advertisement
harleyGnarlz

Wordpress wpdb query

Apr 19th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. function artists_search_country($country_alt){
  2. global $wpdb;
  3. $querystr = "
  4. SELECT wposts.*, meta1.meta_value as meta_value1, meta2.meta_value as meta_value2, meta3.meta_value as meta_value3
  5. FROM $wpdb->posts wposts, $wpdb->postmeta meta1, $wpdb->postmeta meta2, $wpdb->postmeta meta3
  6. WHERE (wposts.ID = meta1.post_id
  7. AND wposts.ID = meta2.post_id
  8. AND wposts.ID = meta3.post_id
  9. )
  10. AND (
  11. (
  12. meta1.meta_key = '_artist_country' AND meta1.meta_value = '$country_alt')
  13. OR
  14. (meta2.meta_key = '_artist_country_sub' AND meta2.meta_value = '$country_alt')
  15. )
  16. AND meta3.meta_key = '_artist_artist_last_name'
  17. AND wposts.post_status = 'publish'
  18. AND wposts.post_type = 'artists'
  19. ORDER BY meta3.meta_value ASC
  20. ";
  21. $myposts = $wpdb->get_results($querystr, OBJECT);
  22. return $myposts;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement