Filter taxonomy archive by a different taxonomy’s terms
Question
I have TAXONOMY A and TAXONOMY B (used with Pages and 2 custom post types). I need the taxonomy.php template used by TAX A to filter by the terms of TAX B. What’s worse, I need to be able to use an existing custom meta value for each of those TAX B terms to dictate the order (clients, amirite?).
I have something kinda similar for a regular post type loop (posted below, FWIW), but can’t get anything working how I need it for an archive function. Any ideas welcome.
<?php $custom_terms = get_terms('CUSTOM_TAX_1');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$customQuery = array(
'post_type' => 'any',
'order' => 'ASC',
'orderby' => 'menu_order',
'tax_query' => array(
array(
'taxonomy' => 'CUSTOM_TAX_1',
'field' => 'slug',
'terms' => $custom_term->slug,
),
),
);
$custom = new WP_Query($customQuery); ?>
<?php if($custom->have_posts()) {
echo '<h6>'.$custom_term->title.'</h6><section>';
while($custom->have_posts()) : $custom->the_post();?>
<div class="entry">
<h4><?php the_title(); ?></h4>
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>
</section>
<?php }
}
?>
<?php wp_reset_query(); ?>
0
2 years
2021-04-13T14:39:35-05:00
2021-04-13T14:39:35-05:00 0 Answers
0 views
0
Leave an answer