Including all terms in wordpress tax_query

Unless you have posts that don’t have a city aren’t you essentially querying all your posts? Anyway, Eric Holmes is correct that you should be using WP_Query in lieu of query_posts().

That said, you can get a list of all the terms in a taxonomy and then use those values in your tax query.

// get all terms in the taxonomy
$terms = get_terms( 'city' ); 
// convert array of term objects to array of term IDs
$term_ids = wp_list_pluck( $terms, 'term_id' );

// proceed with tax query
$args = array ('tax_query' => array(
    array(
        'taxonomy' => 'city',
        'field' => 'term_id',
        'terms' => $term_ids,
         )
)
);

$city_posts = new WP_Query( $args );

Leave a Comment