<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>

CC BY-SA 4.0
2020-11-20T07:37:00.673Z
2020-11-20T07:37:00.673Z
Oli
<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>

<entry><loop>
Output loop position number
# 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 %}
      
         **LOOP NUMBER HERE**  {{ asset.title }}
     
{% 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).
{% for asset in relatedEntries %}
  
  
    {{ loop.index }}  {{ asset.title }}
  
 
{% endfor %}


---

