Hi
I am using Bricks with Metabox AIO. I have 2 CPT "events" and "Rooms". I have a relationship between them and using bricks I can successfully get event info as well as a link to the related room where the event is. So far so good.
I would like to add location information (a field in the Rooms CPT ) to the output and am having trouble.
The following code produces empty results.
function jp_search_customfield_related($customfield_ID, $relationship_ID) {
global $post;
$connected_posts = MB_Relationships_API::get_connected([
'id' => $relationship_ID,
'to' => $post->ID,
]);
// if there are no connected , abort
if (empty($connected_posts)) {
return $connected_posts;
};
foreach ($connected_posts as $connected_post){
$connected_posts_ids[] = $connected_post->ID;
};
$customfield = rwmb_get_value($customefield_ID, '', $connected_posts_ids[0]);
return($customfield);
}
Any help is appreciated. As you can probably see I am not an expert.
Thank you in advance
Dirk