get( $var, false ); if ( false === $value ) { return; } $has_tickets = (bool) $value; /** @var Tribe__Tickets__Cache__Cache_Interface $cache */ $cache = tribe( 'tickets.cache' ); $post_types = (array) $query->get( 'post_type', array( 'post' ) ); $ids = $has_tickets ? $cache->posts_with_ticket_types( $post_types ) : $cache->posts_without_ticket_types( $post_types ); $post__in = $query->get( 'post__in' ); $in = ! empty( $post__in ) ? array_intersect( $post__in, $ids ) : $ids; // empty means no post of this type has/has-no tickets if ( empty( $in ) ) { $in = array( 0 ); } $query->set( 'post__in', $in ); $query->query_vars['post__in'] = $in; } }