1

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

2

You can use Twig's loop variable (docs).

{% 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 %}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.