Relationship not bi-directional

Support MB Relationships Relationship not bi-directional

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #45639
    AndrewAndrew
    Participant

    I have 2 post types:
    book
    book-series

    I have created a relationship between the two so I can display the related books on the book details page based on the series they are in but when I query it I can only return the book-series. If I try to display the list of books I get nothing returned. I've tried using the sample code on the Meta Box help docs site, via a Meta Box View, and using a Oxygen repeater which normally works but none of these methods work.

    Here is the code from my View:

    {% set relationship = attribute( relationships, 'books-by-series' ) %}
    {% for post in relationship.to %}
    	1, {{ post.title }}
    {% endfor %}
    
    {% set relationship = attribute( relationships, 'books-by-series' ) %}
    {% for post in relationship.from %}
    	2, {{ post.title }}
    {% endfor %}

    The first one returns the book series, the second on returns nothing. Any suggestions what could be the issue here?

    #45645
    Anh TranAnh Tran
    Keymaster

    Hi Andrew,

    Can you please share the setup of the relationship (code or screenshot)?

    #45658
    AndrewAndrew
    Participant

    Hi Anh, apologies for the delay getting back to you. Here is a screenshot of the relationship set up.

    Meta Box relationship

    #45659
    AndrewAndrew
    Participant

    null

    #45660
    AndrewAndrew
    Participant
    #45662
    PeterPeter
    Moderator

    Hello Andrew,

    There is only one code that can work on a page. I think the view is assigned to the book series location and the to side (to book series) will work to show the book.

    You can create a new view template, assign it to the book location and the from side (from book) will work to show the book series.

    If that isn't the case, please share the view template settings on your site.

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