code that create the relationnship (sorry not sure if this is what you mean by get the code, I just extracted the php function from the relationship in metabox)
<div>
<?php
add_action( 'mb_relationships_init', 'your_prefix_function_name' );
function your_prefix_function_name() {
MB_Relationships_API::register( [
'id' => 'publisher-book',
'reciprocal' => true,
'from' => [
'object_type' => 'post',
'post_type' => 'publisher',
'meta_box' => [
'priority' => 'high',
'style' => 'seamless',
],
'field' => [
'name' => 'Publisher',
],
],
'to' => [
'object_type' => 'post',
'post_type' => 'book',
'meta_box' => [
'priority' => 'high',
'style' => 'seamless',
],
'field' => [
'name' => 'Books',
'add_button' => 'Add books',
],
],
] );
}
</div>
code that get the books
<div>
<div class="container3">
{% set relationship = attribute( relationships, 'publisher-book' ) %}
{% for post in relationship.to %}
<div class="container4">
<a href="{{ post.url }}">
<img src="{{ post.thumbnail.medium.url }}" width="{{ post.thumbnail.medium.width }}" height="{{ post.thumbnail.medium.height }}" alt="{{ post.thumbnail.medium.alt }}" />
<h4>{{ post.title }}</h4></a>
</div>
{% endfor %}
</div>
</div>
thank you.