Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $customfilter=$_GET["categoryfilter"];
- $start=$_GET["Start"];
- $end=$_GET["End"];
- $s=get_search_query();
- // For Taxonomy
- $termSlug = array();
- $tax_terms = get_terms('myevents', array('hide_empty' => '0'));
- foreach ( $tax_terms as $tax_term ):
- $termSlug[] = $tax_term->slug;
- endforeach;
- //Assigning dates
- $start_date = $start;
- $end_date =$end;
- //Setting dates according to sql format
- $start_date_new = date('Y-m-d', strtotime($start_date));
- $end_date_new = date('Y-m-d', strtotime($end_date));
- $args = array(
- 'post_type' => 'events', //Post type event
- 'orderby' => 'date',
- 'order' => 'DESC',
- 'posts_per_page' => -1,
- 's' =>$s,
- 'meta_query'=>array( //Meta Query search
- 'relation'=>'AND',
- array(
- 'key' => 'start_date',
- 'value' => $start_date_new, //start date here
- 'compare' => '>=',
- 'type' => 'DATE'
- ),
- array(
- 'key' => 'end_date',
- 'value' => $end_date_new, //end date here
- 'compare' => '<=',
- 'type' => 'DATE'
- )
- ),
- 'tax_query' => array(
- array (
- 'taxonomy' => 'myevents', //Taxonomy search
- 'field' => 'slug',
- 'terms' => $termSlug, //terms in array
- )
- ),
- );
- // The Query
- $the_query = new WP_Query( $args );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement