Event query with all age group conditions
// WP_Query arguments $args = array( 'post_type' => array( 'event' ), 'post_status' => array( 'publish' ), 'meta_query' => array( 'relation' => 'OR', array( array( 'key' => 'age_group_from', 'value' => '$ageMin', 'compare' => '<=', ), ), array( array( 'key' => 'age_group_to', 'value' => '$ageMax', 'compare' => '>=', ), ), array( 'relation' => 'AND', array( 'key' => 'age_group_to', 'compare' => 'NOT EXISTS', ), array( 'key' => 'age_group_to', 'compare' => 'NOT EXISTS', ), ), ), ); // The Query $query = new WP_Query( $args );