Use get_categories
to return the terms in each taxonomy then loop through each getting the posts.
$args = array(
'taxonomy' => 'meal_time'
);
$meal_times = get_categories( $args );
foreach ( $meal_times as $meal ) {
echo '<h3 class="meal-title">' . $meal->cat_name . '</h3>'; //Shows the term name as the title then loops through courses
$child_args = array(
'taxonomy' => 'courses'
);
$courses = get_categories( $args );
foreach ( $courses as $course ); {
echo '<h4 class="course-title">' .$course->cat_name. '</h4>'; //Shows the course then gets the posts
$new_args = array(
'cat' => $meal->term_id,$course->term_id,
'posts_per_page' => -1
);
$my_query = new WP_Query( $new_args );
while ( $my_query->have_posts () ) : $my_query->the_post ();
//Do stuff
endwhile;
}
}
This will return:
Lunch
– appetizers
All posts assigned with the Lunch Meal Time term and the Appetizers Course Term
– entrees
All posts assigned with the Lunch Meal Time term and the Entrees Course Term
Dinner
– appetizers
– entrees
etc…