<p>As Douglas mentioned in the comments, if the relation is defined within a Matrix block, then the Matrix block is the source of the relation; not the entry.</p>

<p>Soy you just need to change <code>relatedWorks</code> and <code>relatedPerformers</code> to:</p>

<pre class="lang-twig prettyprint-override"><code>{% set relatedWorks = craft.entries.section('Works').relatedTo(block) %}
{% set relatedPerformers = craft.entries.section('Performers').relatedTo(block) %}
</code></pre>

CC BY-SA 3.0
2014-10-20T23:09:39.127Z
2014-10-20T23:09:39.127Z
Brandon Kelly
<p>I have three sections:</p>

<ol>
<li>Discography</li>
<li>Performers</li>
<li>Works</li>
</ol>

<p>Within "Discography", a Matrix field contains related entries from "Performers" and from "Works".</p>

<p>I am looking to display those related entries in Discography with the code below, but nothing happens (no error, no display):</p>

<pre><code>{% for entry in craft.entries.section('Discography').order('title') %}

    {{ entry.title }}

    {% for block in entry.discoOeuvres %}

        {% set relatedWorks = craft.entries.section('Works').relatedTo(entry) %}
        {% set relatedPerformers = craft.entries.section('Performers').relatedTo(entry) %}

        {% for work in relatedWorks %}
            {{ work.title }}

            {% for performer in relatedPerformers %}
                {{ performer.title }}
            {% endfor %}
        {% endfor %}
    {% endfor %}
{% endfor %}
</code></pre>

<p>Also tried to follow <a href="https://craftcms.stackexchange.com/questions/2287/how-can-i-display-related-entries-selected-within-a-matrix-field">this solution</a>, with no success...</p>

<p>Where do I miss something?</p>

<p>Thanks for helping.</p>

CC BY-SA 3.0
2014-10-20T16:41:24.387Z
I haven't dealt with this specifically, but I know that the relationship is with the `matrix block` and not the `entry`. Have you tried `relatedTo(block)`? (untested). The answer on the page you linked is also correct.
Douglas McDonald
<entries><matrix><relations>
Related entries in Matrix field
# Related entries in Matrix field

(Asked by: username_0 on 2014-10-20)

I have three sections:

Discography
Performers
Works

Within "Discography", a Matrix field contains related entries from "Performers" and from "Works".
I am looking to display those related entries in Discography with the code below, but nothing happens (no error, no display):
{% for entry in craft.entries.section('Discography').order('title') %}

    {{ entry.title }}

    {% for block in entry.discoOeuvres %}

        {% set relatedWorks = craft.entries.section('Works').relatedTo(entry) %}
        {% set relatedPerformers = craft.entries.section('Performers').relatedTo(entry) %}

        {% for work in relatedWorks %}
            {{ work.title }}

            {% for performer in relatedPerformers %}
                {{ performer.title }}
            {% endfor %}
        {% endfor %}
    {% endfor %}
{% endfor %}

Also tried to follow this solution, with no success...
Where do I miss something?
Thanks for helping.

**Tags:** entries, matrix, relations
> **Comments:**
> **username_1**: I haven't dealt with this specifically, but I know that the relationship is with the `matrix block` and not the `entry`. Have you tried `relatedTo(block)`? (untested). The answer on the page you linked is also correct.  

---

## 1 answers

### Answer by username_2 on 2014-10-20. Score: 3 | Accepted answer

As Douglas mentioned in the comments, if the relation is defined within a Matrix block, then the Matrix block is the source of the relation; not the entry.
Soy you just need to change relatedWorks and relatedPerformers to:
{% set relatedWorks = craft.entries.section('Works').relatedTo(block) %}
{% set relatedPerformers = craft.entries.section('Performers').relatedTo(block) %}


---

