I have searched all through the forums and WP docs, but can't find an answer to whether or not WP Meta Query permits a sub meta query. My problem is this: I have a number of types of promos (custom post type) with start and end dates(stored as unixtime in the db). I want to exclude one type of promo ("walls", which is working fine) and also (using OR for either case) exclude items whose start dates AND end dates (IF they exist) are in the past. Here is my code:
$nowtime = time(); $the_query = new WP_Query( array( 'post_type' => 'promos', 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'wpcf-type-of-promo', 'value' => 'walls', 'compare' => 'NOT LIKE' ), array( 'relation' => 'AND', array( 'key' => 'wpcf-date-and-time-start', 'value' => $nowtime, 'compare' => '<', 'type' => 'NUMERIC' ), array( 'key' => 'wpcf-date-and-time-end', 'value' => $nowtime, 'compare' => '<', 'type' => 'NUMERIC' )) ) ));
For the above code, the promo type of "walls" is correctly being filtered out, but the start dates and end dates in the sub query are being completely ignored.