Answers.Body: <p>You can use Twig's loop variable (<a href="https://twig.symfony.com/doc/3.x/tags/for.html#the-loop-variable" rel="nofollow noreferrer">docs</a>).</p>
  <pre><code>{% for asset in relatedEntries %}
  &lt;div id=&quot;locate&quot; class=&quot;locate&quot;&gt;  
    &lt;div class=&quot;portname&quot;&gt;
      &lt;a href=&quot;/memory/index.php/bio/{entry_id}&quot;&gt;{{ loop.index }}  {{ asset.title }}&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt; 
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-20T07:37:00.673Z
Answers.LastActivityDate: 2020-11-20T07:37:00.673Z
Answers.UserDisplayName: Oli
Body: <p>Good Evening,</p>
  <p>This is probably something really simple, but I need to output the position of the entries in a query within the loop</p>
  <pre><code>{% set relatedEntries = craft.entries().section('memories').limit(10).orderby('RAND()') %}
              
  {% for asset in relatedEntries %}
      &lt;div id=&quot;locate&quot; class=&quot;locate&quot;&gt;  
          &lt;div class=&quot;portname&quot;&gt;&lt;a href=&quot;/memory/index.php/bio/{entry_id}&quot;&gt; **LOOP NUMBER HERE**  {{ asset.title }}&lt;/a&gt;&lt;/div&gt;
      &lt;/div&gt; 
  {% endfor %}
  </code></pre>
  <p>I want it to add the number between 1 and 10 depending on its position</p>
  <p>Any help would be appreciated</p>
  
Tags: <entry><loop>
Title: Output loop position number
ThreadText: # Output loop position number
  
  (Asked by: username_0 on 2020-11-19)
  
  Good Evening,
  
  This is probably something really simple, but I need to output the position of the entries in a query within the loop
  
  ```
  {% set relatedEntries = craft.entries().section('memories').limit(10).orderby('RAND()') %}
              
  {% for asset in relatedEntries %}
      <div id="locate" class="locate">  
          <div class="portname"><a href="/memory/index.php/bio/{entry_id}"> **LOOP NUMBER HERE**  {{ asset.title }}</a></div>
      </div> 
  {% endfor %}
  
  ```
  
  I want it to add the number between 1 and 10 depending on its position
  
  Any help would be appreciated
  
  **Tags:** entry, loop
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-20. Score: 2
  
  You can use Twig's loop variable ([docs](https://twig.symfony.com/doc/3.x/tags/for.html#the-loop-variable)).
  
  ```
  {% for asset in relatedEntries %}
  <div id="locate" class="locate">  
    <div class="portname">
      <a href="/memory/index.php/bio/{entry_id}">{{ loop.index }}  {{ asset.title }}</a>
    </div>
  </div> 
  {% endfor %}
  
  ```
  
  
  ---
  
  