Question

I have a wp_query that works great but I can't have both a meta query and a tax_query in it.

<?php 
    $event_query = new WP_Query(
        array( 
          'post_type'  => 'event',        // only query events
          'meta_key'    => 'event-date',  // load up the event_date meta
          'orderby'     => 'meta_value',
          'order'       => 'asc',         // ascending, so earlier events first
          'posts_per_page' => '-1',
          'meta_query'  => array(
             array(         // restrict posts based on meta values
              'key'     => 'event-date',  // which meta to query
              'value'   => date("Y/m/d"),  // value for comparison
              'compare' => '>',          // method of comparison
              'type'    => 'DATE'  )
             ),
          'tax_query' => array(
            array(
                'taxonomy'  => 'event_category',
                'field'     => 'slug',
                'terms'     => $term_id,
                'operator'  => 'IN')

                ),

           ) // end array
        ); // close WP_Query constructor call

?>

I am trying to find all the events in taxonomy $term_id and then make sure they are all in the future and order by ASC

Any ideas?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top