I build a Custom Post Type “Testimonials” and connect it with bidirectional Relationships in Metabox to a certain page or template. Now I dont know how to setup the Condition to hide when there is no testimonial.
Problem: When I set up the usual conidition, the whole section disappears. I cannot choose Metabox relationships in the conditions field.
Christoph gave me the solution in the Inner Circle:
I created two new posts and it works. Still having problems with displaying them on my existing custom post types
function post2post() {
$connected = new WP_Query( [
'relationship' => [
'id' => 'name-of-your-relationship',
'from' => get_the_ID(), // You can pass object ID or full object
],
'nopaging' => true,
] );
return $connected->have_posts();
}
Simply paste that function in a new snippet in WPCodeBox or the snippet plugin of your choice.
In Bricks, you can use it via condition:
Dynamic Data
{echo:get-related-post}
!=
blank field
If there is no related post, your section won’t show.