I have a custom post type called Developments. They are buildings. They have two different taxonomies: City and Status. On the City taxonomy page for one of the buildings I'm trying to show all posts associated with the Status taxonomy.
<?php
// Vars
$status_taxonomy = 'development_status';
$devs = get_terms( array(
'taxonomy' => $status_taxonomy,
'hide_empty' => true,
) );
?>
<?php
foreach($devs as $dev) :
$dev_id = $dev->term_id;
$dev_name = $dev->name;
?>
<?php
$term_slug = $dev->slug;
$dev_posts = new WP_Query( array(
'post_type' => 'developments',
'posts_per_page' => -1, //important for a PHP memory limit warning
'tax_query' => array(
array(
'taxonomy' => $status_taxonomy,
'field' => 'slug',
'terms' => $term_slug,
'operator' => 'IN',
),
),
));
if( $dev_posts->have_posts() ) :
echo '<h3>'. $dev_name .'</h3>';
while ( $dev_posts->have_posts() ) : $dev_posts->the_post();
?>
<div class="col-xs-12">
<h3>$dev_name</h3>
</div>
<div class="col-md-4">
<h4><?php the_title(); ?></h4>
</div>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
<?php
endforeach;
?>
This code outputs all of the Status terms, but it's showing all the posts too, I need it to show posts that are associated to City. I am not sure how to modify the code above to achieve this.