I have 4 custom taxonomies with multiple terms for a "Members" page. I have a taxonomy of "location" and "organize" that I'm trying to separate into a list. I need to grab all posts by the "aba-therapists" term in the "organize" taxonomy and separate those by their "locations." If that makes sense to anyone. Something like this:
ABA Therapist Term of Organize Taxonomy
Term 1 of Location Taxonomy
Post Post Post Post
Term 2 of Location Taxonomy
Post Post Post Post
Term 3 of Location Taxonomy
Post Post Post Post
This is the code I have, which just pulls in every post within the "members" CPT and organizes by every term:
foreach ($taxonomies as $taxonomy){
$terms = get_terms($taxonomy, array('orderby' => 'date', 'order' => 'ASC'));
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
$args = array(
'post_type' => $post_type,
'orderby' => 'date',
'order' => 'ASC',
'ignore_sticky_posts' => 1,
'post_status' => 'publish',
'posts_per_page' => - 1,
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $term->slug
)
)
);
$my_query = null;
$my_query = new WP_Query($args);
if ($my_query->have_posts()) {
echo '<div class="members"><div class="wrap"><h3>' . $term->name . '</h3></div><div class="details"><div class="wrap">';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail('cac-small'); ?>
<?php else : ?>
<img src="<?php echo get_template_directory_uri(); ?>/img/profile-placeholder.png" alt="Default Image">
<?php endif; ?>
<div class="caption">
<p><?php the_title(); ?></p>
</div>
</a>
<?php
endwhile;
} // END if have_posts loop
echo '</div></div></div>'; // Close 'details', 'wrap', & 'members' DIVs
wp_reset_query();
} // END foreach $terms
}
}
?>
I'm lost on where to start. Anyone have any clues?