You can’t, because of the way categories and general taxonomies operate. Categories are a type of taxonomy, so we are querying one level lower when querying for categories. When you query for category__in => array()
it actually looks up what category_terms
are queried and queries posts from all those categories. Now this effect we can mimic.
$terms_in = array(23,34,45,56);
$taxonomy_terms = get_terms( array( 'city' ), array(
'orderby' => 'none',
'hide_empty' => 1,
'include' => $terms_in
) );
foreach ( $taxonomy_terms as $term ) :
$args = array(
'taxonomy' => $term->slug,
'post_status' => 'publish',
'posts_per_page' => -1,
);
$term_name = $term->slug;
$query = new WP_Query( $args );
while( $query->has_posts() ) :
$query->the_post();
// DISPLAY HERE
endwhile;
endforeach;
wp_reset_postdata();
The code above was edited for your specific question.