Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. $customfilter=$_GET["categoryfilter"];
  2. $start=$_GET["Start"];
  3. $end=$_GET["End"];
  4. $s=get_search_query();
  5.  
  6. // For Taxonomy
  7.  
  8. $termSlug = array();
  9. $tax_terms = get_terms('myevents', array('hide_empty' => '0'));
  10. foreach ( $tax_terms as $tax_term ):
  11. $termSlug[] = $tax_term->slug;
  12. endforeach;
  13.  
  14. //Assigning dates
  15.  
  16. $start_date = $start;
  17. $end_date =$end;
  18.  
  19. //Setting dates according to sql format
  20. $start_date_new = date('Y-m-d', strtotime($start_date));
  21. $end_date_new = date('Y-m-d', strtotime($end_date));
  22.  
  23.  
  24. $args = array(
  25. 'post_type' => 'events', //Post type event
  26. 'orderby' => 'date',
  27. 'order' => 'DESC',
  28. 'posts_per_page' => -1,
  29. 's' =>$s,
  30. 'meta_query'=>array( //Meta Query search
  31. 'relation'=>'AND',
  32. array(
  33. 'key' => 'start_date',
  34. 'value' => $start_date_new, //start date here
  35. 'compare' => '>=',
  36. 'type' => 'DATE'
  37. ),
  38. array(
  39. 'key' => 'end_date',
  40. 'value' => $end_date_new, //end date here
  41. 'compare' => '<=',
  42. 'type' => 'DATE'
  43. )
  44. ),
  45. 'tax_query' => array(
  46. array (
  47. 'taxonomy' => 'myevents', //Taxonomy search
  48. 'field' => 'slug',
  49. 'terms' => $termSlug, //terms in array
  50. )
  51. ),
  52.  
  53. );
  54. // The Query
  55. $the_query = new WP_Query( $args );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement