<blockquote>
  <p>Wasn't sure if I need to also setup a field type entries in GamePublishers to reference to Games section.</p>
</blockquote>

<p>Not necessary if you already have a "GamePublishers" Entry field in the "Games" section.</p>

<p>Something like this should work:</p>

<pre><code>{% set games = craft.entries.section('games').relatedTo(publisher) %}
</code></pre>

<p>That's assuming you've already got a variable named <code>publisher</code> defined that's referencing the current publisher the user is viewing.</p>

<p>I'd suggest reading through the <a href="https://craftcms.com/docs/relations" rel="nofollow noreferrer">relations</a> docs as well.  Craft has a pretty powerful relations engine you can do all sorts of crazy stuff with.</p>

CC BY-SA 3.0
2016-12-18T23:36:16.593Z
I tried this but didn't work...

{% extends "_layout" %}

{% block content %}
 <article>
  <h1>{{ entry.title }}</h1>  
  {{ entry.body }}
 </article>
 
 {% set games = craft.entries.section('games').relatedTo(publisher) %}
 <ul>
    {% for entry in entries %}
        <li>
            <a href="{{ entry.url }}">{{ entry.title }}</a> ({{ entry.GamesReleaseYear.format('Y') }})
        </li>
    {% endfor %}
 </ul>
{% endblock %}
DevServe
CC BY-SA 3.0
2016-12-19T00:30:12.403Z
That's a bit hard to read, are you defining the variable `publisher` somewhere?  It should be a reference to the publisher the user is currently viewing.
Brad Bell
CC BY-SA 3.0
2016-12-19T02:11:49.743Z
Ok, I updated it. It is listing games, but it is listing ALL games and not those specific to the publisher. I'm using: {% set entries = craft.entries.section('games').relatedTo(GamesPublisher) %}
DevServe
CC BY-SA 3.0
2016-12-18T17:09:07.333Z
2016-12-18T17:09:07.333Z
Brad Bell
<p>Think I finally got it. Here is my code.</p>

<pre><code>{% extends "_layout" %}

{% block content %}
    &lt;article&gt;
        &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;      
        {{ entry.body }}
    &lt;/article&gt;

    &lt;h2&gt;Games&lt;/h2&gt;

    {% set entries = craft.entries.section('games').relatedTo(entry) %}

    &lt;ul&gt;
        {% for entry in entries.order('title') %}
            &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;{% if entry.GamesGenre is not empty %} ({% for category in entry.GamesGenre %}{{ category.title }}{% endfor %}){% endif %}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;

{% endblock %}
</code></pre>

CC BY-SA 3.0
2016-12-19T02:44:29.743Z
2016-12-19T04:07:05.423Z
2016-12-19T04:07:05.423Z
DevServe
<p>I have two sections:
games
publishers</p>

<p>For example, a games entry title would be "Mario Brothers" and a publishers entry title would be "Nintendo"</p>

<p>On the entry page for Nintendo, I want to display all games (entries) they published.</p>

<p>The "_entry,html" page for publishers right now only has the following code:</p>

<pre><code>{% extends "_layout" %}

{% block content %}
    &lt;article&gt;
        &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;      
        {{ entry.body }}
    &lt;/article&gt;
{% endblock %}
</code></pre>

<p>So I know I need to add it after:</p>

<pre><code>&lt;/article&gt;
</code></pre>

<p>In the games section, I have a field called "GamePublishers" set to type Entries. So I assign the publisher of a game via the admin cp. Wasn't sure if I need to also setup a field type entries in GamePublishers to reference to Games section. (If that makes sense)</p>

<p>Thanks</p>

<entry><sections><loop>
Loop through related section's entries
# Loop through related section's entries

(Asked by: username_0 on 2016-12-18)

I have two sections:
games
publishers
For example, a games entry title would be "Mario Brothers" and a publishers entry title would be "Nintendo"
On the entry page for Nintendo, I want to display all games (entries) they published.
The "_entry,html" page for publishers right now only has the following code:
{% extends "_layout" %}

{% block content %}
    
        {{ entry.title }}      
        {{ entry.body }}
    
{% endblock %}

So I know I need to add it after:


In the games section, I have a field called "GamePublishers" set to type Entries. So I assign the publisher of a game via the admin cp. Wasn't sure if I need to also setup a field type entries in GamePublishers to reference to Games section. (If that makes sense)
Thanks

**Tags:** entry, sections, loop

---

## 2 answers

### Answer by username_1 on 2016-12-18. Score: 1 | Accepted answer

Wasn't sure if I need to also setup a field type entries in GamePublishers to reference to Games section.

Not necessary if you already have a "GamePublishers" Entry field in the "Games" section.
Something like this should work:
{% set games = craft.entries.section('games').relatedTo(publisher) %}

That's assuming you've already got a variable named publisher defined that's referencing the current publisher the user is viewing.
I'd suggest reading through the relations docs as well.  Craft has a pretty powerful relations engine you can do all sorts of crazy stuff with.

> **Comments:**
> **username_0**: I tried this but didn't work...  {% extends "_layout" %}  {% block content %}  <article>   <h1>{{ entry.title }}</h1>     {{ entry.body }}  </article>    {% set games = craft.entries.section('games').relatedTo(publisher) %}  <ul>     {% for entry in entries %}         <li>             <a href="{{ entry.url }}">{{ entry.title }}</a> ({{ entry.GamesReleaseYear.format('Y') }})         </li>     {% endfor %}  </ul> {% endblock %}  
> **username_1**: That's a bit hard to read, are you defining the variable `publisher` somewhere?  It should be a reference to the publisher the user is currently viewing.  
> **username_0**: Ok, I updated it. It is listing games, but it is listing ALL games and not those specific to the publisher. I'm using: {% set entries = craft.entries.section('games').relatedTo(GamesPublisher) %}  

---

### Answer by username_0 on 2016-12-19. Score: 0

Think I finally got it. Here is my code.
{% extends "_layout" %}

{% block content %}
    
        {{ entry.title }}      
        {{ entry.body }}
    

    Games

    {% set entries = craft.entries.section('games').relatedTo(entry) %}

    
        {% for entry in entries.order('title') %}
            {{ entry.title }}{% if entry.GamesGenre is not empty %} ({% for category in entry.GamesGenre %}{{ category.title }}{% endfor %}){% endif %}
        {% endfor %}
    

{% endblock %}


---

