Presumably that would be in your taxonomy-business-location.php
template file then. Here’s what the main content area could look like in such a template, basically:
<div id="main-content">
<?php
$business_location = get_queried_object();
echo "<h1 class="business-location-title">Businesses in " . $business_location->name . ":</h1><hr>"; // Location A, according to your example
$business_categories = get_terms( [
'taxonomy' => 'business-category',
'hide_empty' => true, // hide empty business categories(i.e. have no posts)
] );
$duplicates = []; // more on this later...
// start looping through business categories
foreach ( $business_categories as $business_category ) {
// create new query that gets business listings, that are in Location A business location, and are in the current business category from the foreach loop above
$args = [
'post_type' => 'business-listing',
'tax_query' => [
'relation' => 'AND', // business listings must have both taxonomies terms queried below
[
'taxonomy' => 'business-location',
'field' => 'slug',
'terms' => $business_location->slug,
],
[
'taxonomy' => 'business-category',
'field' => 'slug',
'terms' => $business_category->slug,
],
],
'post__not_in' => $duplicates, // prevents duplicate business listings from showing, you may or may not want this part, more info below...
];
$query = new WP_Query( $args );
if ( $query->have_posts() ) : // don't show business category if no posts in current business category and location
echo "<h2 class="business-category-title">" . $business_category->name . "</h2>";
echo "<ul class="business-listings">";
// looping through business listings
while ( $query->have_posts() ) : $query->the_post();
/* Collect business listing id's and the array gets added
to the next WP_Query's post__not_in. This way a business
listing will only display in the first business category
shown, and none of the other business categories that
the listing is in. Again, this may or may not be wanted.
*/
if( !in_array($post->ID, $duplicates) ) {
$duplicates[] = $post->ID;
}
// output business listing
echo "<li class="business-listing">" . get_the_title() . "</li>";
endwhile;
echo "</ul>";
endif;
}
?>
</div><!-- /#main-content -->
EDIT: Here’s a pic of my business listings data set up, and the output I get if it helps you out: