Query a post relationship in Beaver Themer

Support MB Beaver Builder Integration Query a post relationship in Beaver ThemerResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32560
    paul@wpblueprint.design[email protected]
    Participant

    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

    #32569
    paul@wpblueprint.design[email protected]
    Participant

    This is what I'm talking about

    https://share.getcloudapp.com/mXuP0gyp

    Cheers 🙂

    #32577
    Long NguyenLong Nguyen
    Moderator

    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.

    #32580
    paul@wpblueprint.design[email protected]
    Participant

    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

    #32604
    Long NguyenLong Nguyen
    Moderator

    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

    #32607
    paul@wpblueprint.design[email protected]
    Participant

    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.