Support Forum
Support › Meta Box - Beaver Themer Integrator › Query a post relationship in Beaver ThemerResolved
hi there,
Is it possible to use relationship as query in metabase / Beaver Themer?
E.g. so I can show post module containing posts I have defined as related?
Many thanks
Paul
Hi,
Currently, the extension MB Relationships is not working with the module Posts of the Beaver Builder. I'm going to inform the developer team to consider adding it to the to-do list for the future development of the plugin.
THanks Long,
Much appreciated.
To be honest I can achieve exactly what I need in views, but I don't know how to add if statement that checks if there are any items in the loop.
E.g. if there are no related posts the don't display the "Related posts" text and the ul
I know I am probably 2 lines away from this, but I can't figure it out (I tried some things but failed).
Would you mind showing me the snippet? With this it is the last thing I could not achieve with ACF / Themer Integration.
{% set relationship = attribute( relationships, 'test-rel' ) %}
Related posts
<ul>
{% for post in relationship.to %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
Thanks in advance!
Paul
Hi,
You can check if there is a post in the relationship to show the word "Related posts" and code block inside the condition, just like this
{% if relationship.to is not empty %}
Relationship:
{% for post in relationship.to %}
{{ post.title }}
{% endfor %}
{% endif %}
Refer to this documentation of Twig https://twig.symfony.com/doc/2.x/tests/empty.html
Absolutely amazing. I was looking at this is not empty and it was one of the next "guesses" I was going to try - for some reason I didn't try it.
This worked absolutely perfectly and it means that metabox no having this feature in this screenshot is not a problem at all - I can just drop a shortcode into my single post templates and in fact I can totally control the markup 🙂
https://share.getcloudapp.com/mXuP0gyp - so this is no longer a problem 🙂
Thanks very much!
Cheers
Paul