In case anyone runs into trouble like I did, I figured it out!
$taxonomy_1 = get_terms( 'taxonomy_1', $args_1 );
$taxonomy_2 = get_terms( 'taxonomy_2', $args_2 );
foreach( $taxonomy_1 as $tax_1 ) {
foreach( $taxonomy_2 as $tax_2 ) {
$posts = get_posts(
array(
'posts_per_page' => -1,
'post_type' => 'ENTER-YOUR-CPT',
'order' => 'ASC',
'orderby' => 'title',
'taxonomy' => $tax_2->taxonomy,
'term' => $tax_2->slug,
)
);
foreach( $posts as $post ) {
setup_postdata( $post );
// ENTER YOUR OWN LOOP the_title(), the_permalink(), etc.
}
}
}
In my case, $taxonomy_1
was my letter (reference_letter) and $taxonomy_2
was my type (medium_reference).
Also in this method, it sorts the posts into their taxonomies based on two $tax_2->
lines in the get_posts()
.