Answers.Body: <p>The issue is: you don't really loop your entries at all.</p>
  
  <pre class="lang-TWIG prettyprint-override"><code>{# get all super table rows #}
  {% set superTableRows = block.related.all %}
  
  {% if superTableRows is not empty %}
      &lt;div class="{{ padding }} {{ fontsize }}" id="{{ blockID }}"&gt;
          &lt;div class="{{ margin }}"&gt;
  
              {# loop all of your super tables #}
              {% for row in superTableRows %}
  
                  {# loop all contentEntries in each row #}
                  {% for entry in row.contentEntry.all() %}
  
                      {# 
                          display the alternative title set in your supertablerow 
                          and if thats not set display the entries title
                      #}
                      {{ row.altTitle?? entry.title }}
  
                      {# same as above #}
                      {{ row.altDescription ?? entry.previewDescription }}
  
                  {% endfor %}
              {% endfor %}
          &lt;/div&gt;
      &lt;/div&gt;
  {% endif %}
  </code></pre>
  
  <p><code>block.related</code> is an Object of type <code>ElementQuery</code>. <code>block.related.altDescription</code> returns the criteria of this Query, this is mostly empty since no criteria is set by default. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-21T09:22:55.640Z
Answers.Text: Thanks Robin! superTables should be superTableRows in this example.
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-21T09:24:06.497Z
Answers.Text: Uh yeah copy paste fail. Does it work for you?
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-21T09:27:05.037Z
Answers.Text: Yes, this is working well! Some coding efficiency in there too which is appreciated as a learning point.
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-20T19:19:05.823Z
Answers.LastActivityDate: 2019-03-21T09:23:39.330Z
Answers.LastEditDate: 2019-03-21T09:23:39.330Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I need to loop related entries. </p>
  
  <p>I am using a SuperTable field with the handle "related" with an entry field with the handle "contentEntry" and two text fields for alternative text and descriptions.</p>
  
  <p>The "contentEntry" field is limited to two entries being selected. The issue I'm having is that the following code repeats the first entry twice and doesn't loop and display the second. What am I doing wrong?</p>
  
  <pre><code>{# Related Entry #}
  
  {% set relatedEntries = block.related.all %}
  {% set relatedEntry = block.related.contentEntry.all() %}
  {% set relatedAltDesc = block.related.altDescription %}
  {% set relatedAltTitle = block.related.altTitle %}
  
  
  {% if relatedEntries %}
  
  &lt;div class="{{ padding }} {{ fontsize }}" id="{{ blockID }}"&gt;
      &lt;div class="{{ margin }}"&gt;
  
              {% for entries in relatedEntries %}
  
                {% for rel in relatedEntry %}
  
                  {% if relatedAltTitle %}
                    {{ relatedAltTitle }}
                  {% else %}
                    {{ rel.title }}
                  {% endif %}
  
  
                  {% if relatedAltDesc %}
                    {{ relatedAltDesc }}
                  {% else %}
                    {{ rel.previewDescription }}
                  {% endif %}
  
                {% endfor %}
  
              {% endfor %}
  
      &lt;/div&gt;
  &lt;/div&gt;
  
  {% endif %}
  </code></pre>
  
  <p><a href="https://i.sstatic.net/jEZ66.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jEZ66.png" alt="enter image description here"></a></p>
  
Tags: <templating><forloop><plugin-supertable>
Title: Looping Related Entries with a Super Table
ThreadText: # Looping Related Entries with a Super Table
  
  (Asked by: username_0 on 2019-03-20)
  
  I need to loop related entries.
  
  I am using a SuperTable field with the handle "related" with an entry field with the handle "contentEntry" and two text fields for alternative text and descriptions.
  
  The "contentEntry" field is limited to two entries being selected. The issue I'm having is that the following code repeats the first entry twice and doesn't loop and display the second. What am I doing wrong?
  
  ```
  {# Related Entry #}
  
  {% set relatedEntries = block.related.all %}
  {% set relatedEntry = block.related.contentEntry.all() %}
  {% set relatedAltDesc = block.related.altDescription %}
  {% set relatedAltTitle = block.related.altTitle %}
  
  {% if relatedEntries %}
  
  <div class="{{ padding }} {{ fontsize }}" id="{{ blockID }}">
      <div class="{{ margin }}">
  
              {% for entries in relatedEntries %}
  
                {% for rel in relatedEntry %}
  
                  {% if relatedAltTitle %}
                    {{ relatedAltTitle }}
                  {% else %}
                    {{ rel.title }}
                  {% endif %}
  
                  {% if relatedAltDesc %}
                    {{ relatedAltDesc }}
                  {% else %}
                    {{ rel.previewDescription }}
                  {% endif %}
  
                {% endfor %}
  
              {% endfor %}
  
      </div>
  </div>
  
  {% endif %}
  
  ```
  
  [![enter image description here](https://i.sstatic.net/jEZ66.png)](https://i.sstatic.net/jEZ66.png)
  
  **Tags:** templating, forloop, plugin-supertable
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-20. Score: 2 | Accepted answer
  
  The issue is: you don't really loop your entries at all.
  
  ```TWIG
  {# get all super table rows #}
  {% set superTableRows = block.related.all %}
  
  {% if superTableRows is not empty %}
      <div class="{{ padding }} {{ fontsize }}" id="{{ blockID }}">
          <div class="{{ margin }}">
  
              {# loop all of your super tables #}
              {% for row in superTableRows %}
  
                  {# loop all contentEntries in each row #}
                  {% for entry in row.contentEntry.all() %}
  
                      {# 
                          display the alternative title set in your supertablerow 
                          and if thats not set display the entries title
                      #}
                      {{ row.altTitle?? entry.title }}
  
                      {# same as above #}
                      {{ row.altDescription ?? entry.previewDescription }}
  
                  {% endfor %}
              {% endfor %}
          </div>
      </div>
  {% endif %}
  
  ```
  
  `block.related` is an Object of type `ElementQuery`. `block.related.altDescription` returns the criteria of this Query, this is mostly empty since no criteria is set by default.
  
  > **Comments:**
  > **username_0**: Thanks username_1! superTables should be superTableRows in this example.  
  > **username_1**: Uh yeah copy paste fail. Does it work for you?  
  > **username_0**: Yes, this is working well! Some coding efficiency in there too which is appreciated as a learning point.  
  
  ---
  
  