Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function my_posts_where( $where ) {
  2.  
  3. $where = str_replace("meta_key = 'document_%", "meta_key LIKE 'document_%", $where);
  4.  
  5. return $where;
  6. }
  7.  
  8. add_filter('posts_where', 'my_posts_where');
  9.  
  10.  
  11.  
  12. $args = array(
  13. 'numberposts' => -1,
  14. 'post_type' => 'course',
  15. 'meta_query' => array(
  16. 'relation' => 'AND',
  17. array(
  18. 'key' => 'document_%_type',
  19. 'value' => $document,
  20. 'compare' => 'IN'
  21. ),
  22. array(
  23. 'key' => 'form_of_edu',
  24. 'value' => $form_of_edu,
  25. 'compare' => 'IN'
  26. ),
  27. array(
  28. 'key' => 'type',
  29. 'value' => $type,
  30. 'compare' => 'IN'
  31. )
  32. )
  33. );
  34.  
  35. $query = new WP_Query( $args );
  36. $arr = $query->posts;
  37.  
  38. print_r($arr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement