$terms = get_terms('location', array('orderby' => 'date', 'order' => 'ASC'));
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(
'relation' => 'AND',
array(
'taxonomy' => 'organize',
'field' => 'slug',
'terms' => array( 'aba-therapist' )
),
array(
'taxonomy' => 'location',
'field' => 'slug',
'terms' => array( $term->slug )
)
)
);
$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="https://wordpress.stackexchange.com/questions/155358/<?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
wp_reset_postdata();
}
Hope this code fill work for you. add ABA therapist header above.