Hi,
I'm trying to display a list of custom post types with the title of any related posts next to it in the list.
The list of cpts has an id of 'bookings' and the related posts have an id of 'contacts'.
here's my code but no related posts are displaying...
$loop = new WP_Query(
array(
'post_type' => 'bookings'
)
);
while ( $loop->have_posts() ) : $loop->the_post();
echo the_title();
echo '<br/>';
$contacts = MB_Relationships_API::get_connected( [
'id' => 'bookings_to_contacts',
'from' => get_the_ID(),
] );
foreach ( $contacts as $c ) {
echo $c->post_title;
}
endwhile;
wp_reset_postdata();