Answers.Body: <p>Your query isn't working because you're querying the section, not the individual matrix blocks. I think that's the root cause of the issue.</p>
  <p>Sidenote: Since each matrix block is an element of its own, your <code>nflDraft2021</code> is only indirectly related to the other two sections (i.e. the <code>nflDraft2021</code> is related to a matrix block which is related to <code>draftClass2021</code> and <code>nflTeams</code> entries).</p>
  <p>For the record, here's how to use the related parameter if you're querying for related entries inside a matrix block. You need to explicitly pass the field:</p>
  <pre><code>{% set nflDraft2021 = craft.entries()
      .section('nflDraft2021')
      .relatedTo({
          targetElement: entry,
          field: 'SelectionInfo.draftedBy',
      })
      .all()
  %}
  </code></pre>
  <p>See <a href="https://craftcms.com/docs/3.x/relations.html#going-through-matrix" rel="nofollow noreferrer">Going Through Matrix in the documentation</a></p>
  <p><strong>However</strong>, if I'm understanding your setup correctly, <code>nflDraft2021</code> is a single? In this case, you don't want to find the <code>nflDraft2021</code> entry, but the individual <code>SelectionInfo</code> matrix blocks in which the current team is selected in the <code>draftedBy</code> field, correct?</p>
  <p>In this case, the entries query won't work since it can only return entries, not individual matrix blocks. You need to use a <a href="https://craftcms.com/docs/3.x/matrix-blocks.html#querying-matrix-blocks" rel="nofollow noreferrer">Matrix Block Query</a> instead:</p>
  <pre><code>{% set nflDraft2021 = craft.entries.section('nflDraft2021').one() %}
  {% set currentTeamPicks = craft.matrixBlocks()
      .owner(nflDraft2021)
      .field('SelectionInfo')
      .draftedBy(entry)
      .all()
  %}
  </code></pre>
  <p>Now this will give you an array of matrix blocks, not an array of picked players, so you'll need to access the <code>playerSelected</code> field to get the actual players:</p>
  <pre><code>{% set currentTeamPlayers = currentTeamPicks|map(pick =&gt; pick.playerSelected.one() %}
  </code></pre>
  <p>Still not sure if I understand your setup completely, so there might be some errors in the examples, but hopefully this will help you get back on track!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-02T18:48:27.493Z
Answers.Text: Thank you for the help! nflDraft2021 is a Channel, not a single. All three are channels. I didn't know the matrix block changed that relationship, thanks. I'm going to work through your code later but thanks again for all the help.
Answers.UserDisplayName: doctorgloom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-09T08:33:21.813Z
Answers.Text: @doctorgloom If this solved your issue, would you mind marking my answer as accepted? Thanks!
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-09T17:20:59.177Z
Answers.Text: Sorry about that, I thought I had marked it.
Answers.UserDisplayName: doctorgloom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-02T15:00:30.520Z
Answers.LastActivityDate: 2021-07-02T15:10:43.777Z
Answers.LastEditDate: 2021-07-02T15:10:43.777Z
Answers.UserDisplayName: MoritzLost
Body: <p>I'm trying to get a simple Reverse Entries working, nothing fancy, but I'm stumped.</p>
  <p>I created a little personal project just to help me stretch and learn Craft better. I picked the NFL Draft just because it was an easy dataset (and the draft is fun). This isn't a live project, just something running in MAMP for learning purposes.</p>
  <p>This is the structure:</p>
  <p><strong>I have 3 Channels (no singles)</strong>:</p>
  <p>*<code>nflDraft2021</code> (each draft pick, with Entries fields for the other 2
  channels)</p>
  <p>*<code>draftClass2021</code> (the available players)</p>
  <p>*<code>nflTeams</code> (the teams selecting)</p>
  <p><strong>The <code>nflDraft2021</code> channel has a Matrix field:</strong></p>
  <ul>
  <li><p><strong>Matrix Field Handle:</strong> <code>draftInfo</code></p>
  </li>
  <li><p><strong>Block handle:</strong> <code>SelectionInfo</code></p>
  </li>
  <li><p><strong>Fields in block:</strong> two <em>Entries</em> fields: <code>playerSelected</code> and <code>draftedBy</code> (Those relate to the <em>draftClass2021</em> and <em>nflTeams</em> channels).</p>
  </li>
  </ul>
  <p>What I'm trying to do is on each Team page (the 32 entries in <code>nflTeams</code> channel), have the Related Draft Picks for that team.</p>
  <p>I've tried to follow along to <a href="https://straightupcraft.com/articles/introduction-to-relations-and-reverse-relations-in-craft-cms-with-examples" rel="nofollow noreferrer">this tutorial</a> and came up with this attempt:</p>
  <pre><code>{% set myEntryQuery = craft.entries()
      .section('nflTeams')
      .all() %}
      
  {# title for team page #}   
  &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
  
  {# get the related entries from the nflDraft2021 channel #}
  {% set players = craft.entries.section('nflDraft2021').relatedTo(entry) %}
  
  {% for player in players %}
    {{ player.title }}
  {% endfor %}
  </code></pre>
  <p>I also tried using <a href="https://craftcms.stackexchange.com/questions/10454/reverse-relationships">entry like this post</a>, but still nothing.</p>
  <p>I am trying to get the title of the related entry first before attempting to get something from the Matrix field, but that would be my next goal if I can get the first step working.</p>
  <p>The team page title shows up but that's it, the reverse entries don't do anything, not even an error. So, I'm obviously misunderstanding something but I'm not sure what. Any advice or help appreciated.</p>
  
Tags: <matrix><relations><entries-field>
Title: Can't get a simple Reverse Relations for Entries field to work
ThreadText: # Can't get a simple Reverse Relations for Entries field to work
  
  (Asked by: username_0 on 2021-07-02)
  
  I'm trying to get a simple Reverse Entries working, nothing fancy, but I'm stumped.
  
  I created a little personal project just to help me stretch and learn Craft better. I picked the NFL Draft just because it was an easy dataset (and the draft is fun). This isn't a live project, just something running in MAMP for learning purposes.
  
  This is the structure:
  
  **I have 3 Channels (no singles)**:
  
  \*`nflDraft2021` (each draft pick, with Entries fields for the other 2
  channels)
  
  \*`draftClass2021` (the available players)
  
  \*`nflTeams` (the teams selecting)
  
  **The `nflDraft2021` channel has a Matrix field:**
  
  * **Matrix Field Handle:** `draftInfo`
  * **Block handle:** `SelectionInfo`
  * **Fields in block:** two *Entries* fields: `playerSelected` and `draftedBy` (Those relate to the *draftClass2021* and *nflTeams* channels).
  
  What I'm trying to do is on each Team page (the 32 entries in `nflTeams` channel), have the Related Draft Picks for that team.
  
  I've tried to follow along to [this tutorial](https://straightupcraft.com/articles/introduction-to-relations-and-reverse-relations-in-craft-cms-with-examples) and came up with this attempt:
  
  ```
  {% set myEntryQuery = craft.entries()
      .section('nflTeams')
      .all() %}
      
  {# title for team page #}   
  <h1>{{ entry.title }}</h1>
  
  {# get the related entries from the nflDraft2021 channel #}
  {% set players = craft.entries.section('nflDraft2021').relatedTo(entry) %}
  
  {% for player in players %}
    {{ player.title }}
  {% endfor %}
  
  ```
  
  I also tried using [entry like this post](https://craftcms.stackexchange.com/questions/10454/reverse-relationships), but still nothing.
  
  I am trying to get the title of the related entry first before attempting to get something from the Matrix field, but that would be my next goal if I can get the first step working.
  
  The team page title shows up but that's it, the reverse entries don't do anything, not even an error. So, I'm obviously misunderstanding something but I'm not sure what. Any advice or help appreciated.
  
  **Tags:** matrix, relations, entries-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-02. Score: 2 | Accepted answer
  
  Your query isn't working because you're querying the section, not the individual matrix blocks. I think that's the root cause of the issue.
  
  Sidenote: Since each matrix block is an element of its own, your `nflDraft2021` is only indirectly related to the other two sections (i.e. the `nflDraft2021` is related to a matrix block which is related to `draftClass2021` and `nflTeams` entries).
  
  For the record, here's how to use the related parameter if you're querying for related entries inside a matrix block. You need to explicitly pass the field:
  
  ```
  {% set nflDraft2021 = craft.entries()
      .section('nflDraft2021')
      .relatedTo({
          targetElement: entry,
          field: 'SelectionInfo.draftedBy',
      })
      .all()
  %}
  
  ```
  
  See [Going Through Matrix in the documentation](https://craftcms.com/docs/3.x/relations.html#going-through-matrix)
  
  **However**, if I'm understanding your setup correctly, `nflDraft2021` is a single? In this case, you don't want to find the `nflDraft2021` entry, but the individual `SelectionInfo` matrix blocks in which the current team is selected in the `draftedBy` field, correct?
  
  In this case, the entries query won't work since it can only return entries, not individual matrix blocks. You need to use a [Matrix Block Query](https://craftcms.com/docs/3.x/matrix-blocks.html#querying-matrix-blocks) instead:
  
  ```
  {% set nflDraft2021 = craft.entries.section('nflDraft2021').one() %}
  {% set currentTeamPicks = craft.matrixBlocks()
      .owner(nflDraft2021)
      .field('SelectionInfo')
      .draftedBy(entry)
      .all()
  %}
  
  ```
  
  Now this will give you an array of matrix blocks, not an array of picked players, so you'll need to access the `playerSelected` field to get the actual players:
  
  ```
  {% set currentTeamPlayers = currentTeamPicks|map(pick => pick.playerSelected.one() %}
  
  ```
  
  Still not sure if I understand your setup completely, so there might be some errors in the examples, but hopefully this will help you get back on track!
  
  > **Comments:**
  > **username_0**: Thank you for the help! nflDraft2021 is a Channel, not a single. All three are channels. I didn't know the matrix block changed that relationship, thanks. I'm going to work through your code later but thanks again for all the help.  
  > **username_1**: @username_0 If this solved your issue, would you mind marking my answer as accepted? Thanks!  
  > **username_0**: Sorry about that, I thought I had marked it.  
  
  ---
  
  