Figured it out!
$state_tax_args = array(
'post_type' => 'products',
'orderby' => 'name',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'product-line',
'field' => 'slug',
'terms' => $pl_slug // provided at page load
),
),
);
$state_tax_query = new WP_Query( $state_tax_args );
// counter to build array
$i=0;
if ( $state_tax_query->have_posts()) {
$state_term_list="<select class="form-control" id="inputStateSelect" placeholder="State" name="stateSelect">";
$state_term_list.='<option value="">...</option>';
$states = array();
while ( $state_tax_query->have_posts()){ $state_tax_query->the_post();
$state_terms = wp_get_post_terms( get_the_id(), 'state', $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all'));
foreach($state_terms as $state_term){
$states[$i] = $state_term->name;
$i++;
} // end foreach
} // end while
// kill the dupes
$state_results = array_unique($states);
// alphebatize
asort($state_results);
// build option list
foreach($state_results as $state_result){
$state_term_list.='<option value="' . $state_result . '">' . $state_result . '</option>';
}
$state_term_list.='</select>';
echo $state_term_list;
} // end if
wp_reset_query();
That said, if I’m doing this just bonkers inefficiently, I’m always open to suggestions 🙂