Hi,
I see many threads of MB users not succeeding in showing results from relationships, and I'm joining the group.
I have a relationship from students to courses (as I want to show students the courses he's (been) enrolled in).
In the database there is so far just 1 student with 2 courses. I'm logged in as that student.
I keep the code really basic, just to make sure that the logic of getting the courses for this student works. Next step will be to extend the info that will be shown.
Inspired by the example on https://metabox.io/mb-views-how-to-display-relationships/
{% set args = {post_type: 'courses', nopaging: true, relationship: {id: 'student-results', from: user.ID}} %}
{% set courses = mb.get_posts( args ) %}
{% for course in courses %}
Yes - {{ course.post_ID }}
{% endfor %}
Perhaps even course.post_ID is not correct, but at least I should see 2 lines of Yes. But nothing is shown.
Then I tried different code inspired on https://docs.metabox.io/extensions/mb-views/#relationship-fields
{% set relationship = attribute( relationships, 'student-results' ) %}
{% for user in relationship.from %}
Yes - {{ user.post_ID }}
{% endfor %}
Again, nothing is shown.
I'm really struggling with this, and have spent lots of time already in getting it working.
Pls advise.
Thanks.