Guest User

Untitled

a guest
Aug 24th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2. function get_schools_by_custom_search() {
  3. global $wpdb;
  4. $type = $_GET['type'];
  5. $programme = $_GET['programme'];
  6. $type_sql = " AND wpostmeta.meta_key = 'type' AND wpostmeta.meta_value = '$type' ";
  7. $programme_sql = " AND wpostmeta.meta_key = 'programme' AND wpostmeta.meta_value LIKE '%$programme%' ";
  8.  
  9. $querystr = "
  10. SELECT DISTINCT wposts.*
  11. FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
  12. WHERE wposts.post_status = 'publish'
  13. AND wposts.post_type = 'post'
  14. " . $type_sql . "
  15. " . $programme_sql . "
  16. ORDER BY wposts.post_title DESC
  17. ";
  18.  
  19. $searched_posts = $wpdb->get_results($querystr);
  20. return $searched_posts;
  21. }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment