Hello,
I created the following CPTs and relationships: Trip > TripDay > Event; Trip to TripDay 1:m, TripDay to Event 1:m.
I am trying to create a query in MB Views that retrieves and displays data from a Trip, its associated TripDays and all events associated with each TripDay.
With the help of the following support topic https://support.metabox.io/topic/displaying-2-custom-post-types-via-a-relationship-custom-post-type/ I was able to create a working writing PHP code (see below).
<?php the_title(); ?>
<?php
$connected_tripday = new WP_Query( [
'relationship' => [
'id' => 'relationship-trip-to-tripday',
'from' => get_the_ID(),
],
'nopaging' => true,
] );
while ( $connected_tripday->have_posts() ) : $connected_tripday->the_post();
the_title();
$connected_event = new WP_Query( [
'relationship' => [
'id' => 'relationship-trip-day-to-event',
'from' => get_the_ID(),
],
'nopaging' => true,
] );
while ( $connected_event->have_posts() ) : $connected_event->the_post();
the_title();
endwhile;
$connected_event->wp_reset_postdata();
endwhile;
wp_reset_postdata();
?>
However I would much rather accomplish this in MB Views but have been unable to so far. I am able to retrieve TripDays related to a trip but not Events related to a TripDay.
How can I accomplish this use case in MB Views?
Thank you in advance.
Andy