Answers.Body: <p>I had a similar problem to yours, and here's what I ran into. </p>
  
  <p>It may be that you're using <em>entry</em> for your main info on the retailer entry page? Because <code>{{ for entry in relatedProducts }}</code> would return one result (the retailer entry). So instead, use a different variable for the loop. </p>
  
  <p>Try something more along the lines of this:</p>
  
  <pre><code>&lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
  &lt;div&gt;{{ entry.body }}&lt;/div&gt;
  
  {% if craft.entries.section('products').relatedTo(entry)|length %}
    {% set relatedProducts = craft.entries.section('products').relatedTo(entry) %}
    &lt;h3&gt;Some great entries&lt;/h3&gt;
  
    {% for relatedEntry in relatedProducts %}
     {{ relatedEntry.title }}
     {{ relatedEntry.body }}
    {% endfor %}
  {% endif %}
  </code></pre>
  
  <p>Also, note that I wrapped the whole thing in an if-check. It checks to see if there are related products first, and then, if there are, sets the variable and runs the loop.</p>
  
  <p>And your H3 should be outside the loop, otherwise it'll show up on every pass around.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-26T16:42:37.577Z
Answers.LastActivityDate: 2017-06-26T16:42:37.577Z
Answers.UserDisplayName: SamC
Body: <p>Trying to list all the entries which belong to an entry. Currently I have the following field format:</p>
  
  <ul>
  <li>Product
  
  <ul>
  <li>Has an 'retailer' entries field.</li>
  </ul></li>
  <li>Retailer
  
  <ul>
  <li>Normal entry.</li>
  </ul></li>
  </ul>
  
  <p>On the retailers _entry.html page I'm trying to display all the products which belong to said retailer. But the code I'm producing is running into trouble:</p>
  
  <p><strong>retailers/_entry.html</strong></p>
  
  <pre><code>    {% set relatedProducts = craft.entries.section('products').relatedTo(entry) %}
  
      {% for entry in relatedProducts %}
          &lt;h3&gt;Some great entries&lt;/h3&gt;
      {% endfor %}
  </code></pre>
  
  <p>This code seems to be showing the title but not actually looping over the length of the array?</p>
  
Tags: <entries><relations>
Title: Listing all entries which belong to an entry
ThreadText: # Listing all entries which belong to an entry
  
  (Asked by: username_0 on 2017-06-26)
  
  Trying to list all the entries which belong to an entry. Currently I have the following field format:
  
  * Product
    + Has an 'retailer' entries field.
  * Retailer
    + Normal entry.
  
  On the retailers \_entry.html page I'm trying to display all the products which belong to said retailer. But the code I'm producing is running into trouble:
  
  **retailers/\_entry.html**
  
  ```
      {% set relatedProducts = craft.entries.section('products').relatedTo(entry) %}
  
      {% for entry in relatedProducts %}
          <h3>Some great entries</h3>
      {% endfor %}
  
  ```
  
  This code seems to be showing the title but not actually looping over the length of the array?
  
  **Tags:** entries, relations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-26. Score: 3 | Accepted answer
  
  I had a similar problem to yours, and here's what I ran into.
  
  It may be that you're using *entry* for your main info on the retailer entry page? Because `{{ for entry in relatedProducts }}` would return one result (the retailer entry). So instead, use a different variable for the loop.
  
  Try something more along the lines of this:
  
  ```
  <h1>{{ entry.title }}</h1>
  <div>{{ entry.body }}</div>
  
  {% if craft.entries.section('products').relatedTo(entry)|length %}
    {% set relatedProducts = craft.entries.section('products').relatedTo(entry) %}
    <h3>Some great entries</h3>
  
    {% for relatedEntry in relatedProducts %}
     {{ relatedEntry.title }}
     {{ relatedEntry.body }}
    {% endfor %}
  {% endif %}
  
  ```
  
  Also, note that I wrapped the whole thing in an if-check. It checks to see if there are related products first, and then, if there are, sets the variable and runs the loop.
  
  And your H3 should be outside the loop, otherwise it'll show up on every pass around.
  
  
  ---
  
  