I've got a relationship between two CPTs, on the Relationship UI, it's not marked as a Reciprocal relationship (left unchecked). On each post type edit page, the relationship appears and works without any issues.
Now, I'm trying to display CPT-A 'Projects' related to CPT-B 'Awards' on each frontend post.
Here's the view to be displayed in a Project, which is working just fine:
{% set args = {
'post_type': 'award',
'nopaging': true,
'relationship': {
'id': 'projects-and-awards',
'from': post.ID,
}
}
%}
{% set awards = mb.get_posts( args ) %}
{% for award in awards %}
<p><a href="{{ award.url }}" alt="{{award.post_title}}">{{award.post_title}}</a></p>
{% endfor %}
And here's the view to be displayed in an Award, that's not displaying anything, as if the loop was empty (the view works, tried it by placing the {{post.id}}
and some static strings):
{% set args = {
'post_type': 'project',
'nopaging': true,
'relationship': {
'id': 'proyectos-y-premios',
'from': post.ID,
}
}
%}
{% set projects = mb.get_posts( args ) %}
{% for project in projects %}
<p><a href="{{ project.url }}" alt="{{project.post_title}}">{{project.post_title}}</a></p>
{% endfor %}
I'm not sure why on the Award post, it's not showing anything, however on the Project post it's working without any issue.