<p>Since you're using pagination, you can calculate the offset using the current page and number of items per page.</p>
<pre class="lang-twig prettyprint-override"><code>{% set limit = 10 %}
{% set archiveQuery = craft.entries()
    .section('blog')
    .limit(limit)
%}

{% paginate archiveQuery as pageInfo, posts %}

{% set offset = (pageInfo.currentPage - 1) * limit %}

{% for post in posts %}
    Entry {{ offset + loop.index }} of {{ pageInfo.total }}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2024-07-09T17:03:57.870Z
Brilliant ! Thx a lot !
Artur Potosyan
CC BY-SA 4.0
2024-07-09T08:35:45.607Z
2024-07-09T08:35:45.607Z
MoritzLost
<p>I’m not sure if this is what you’re asking for, but you can number fetched entries inside a <code>for</code> loop in Twig using the current iteration of the loop (<code>loop.index</code>).</p>
<pre><code>{% set entries = craft.entries.all() %}
{% for entry in entries %}
    Entry #{{ loop.index }} of {{ entries|length }}
{% endfor %}
</code></pre>
<p>To make this work when paginating entries, you can add the current page’s first entry number (<code>pageInfo.first</code>) to the zero-indexed iteration of the loop (<code>loop.index0</code>).</p>
<pre><code>{% set entryQuery = craft.entries.limit(10) %}
{% paginate entryQuery as pageInfo, entries %}
{% for entry in entries %}
    Entry #{{ pageInfo.first + loop.index0 }} of {{ pageInfo.total }}
{% endfor %}
</code></pre>
<p>References:<br />
<a href="https://craftcms.com/docs/5.x/development/element-queries.html#navigating-pages" rel="nofollow noreferrer">https://craftcms.com/docs/5.x/development/element-queries.html#navigating-pages</a><br />
<a href="https://twig.symfony.com/doc/3.x/tags/for.html#the-loop-variable" rel="nofollow noreferrer">https://twig.symfony.com/doc/3.x/tags/for.html#the-loop-variable</a></p>

CC BY-SA 4.0
2024-07-08T10:07:05.100Z
ok, thx, will try and let you know
Artur Potosyan
CC BY-SA 4.0
2024-07-08T19:48:54.233Z
It works, but, for pagination state, for every next page, it starts from 1 of total, rather than continuing from the previous page.
Artur Potosyan
CC BY-SA 4.0
2024-07-09T17:24:07.863Z
You didn’t mention that in your question, but I’ve added a second code sample to my answer for the case when you’re paginating entries.
Ben Croker
CC BY-SA 4.0
2024-07-08T09:21:39.950Z
2024-07-09T17:23:24.443Z
2024-07-09T17:23:24.443Z
Ben Croker
<p>is there any way to add ascending numbers to entries archive, i.e. Entry #1 of 100, Entry #2 of 100, #3 of 100 etc. Thanks in advance.</p>

<number>
Numbering of entries (1, 2, 3 ...)
# Numbering of entries (1, 2, 3 ...)

(Asked by: username_0 on 2024-07-08)

is there any way to add ascending numbers to entries archive, i.e. Entry #1 of 100, Entry #2 of 100, #3 of 100 etc. Thanks in advance.

**Tags:** number


---

## 2 answers

### Answer by username_1 on 2024-07-09. Score: 1

Since you're using pagination, you can calculate the offset using the current page and number of items per page.
{% set limit = 10 %}
{% set archiveQuery = craft.entries()
    .section('blog')
    .limit(limit)
%}

{% paginate archiveQuery as pageInfo, posts %}

{% set offset = (pageInfo.currentPage - 1) * limit %}

{% for post in posts %}
    Entry {{ offset + loop.index }} of {{ pageInfo.total }}
{% endfor %}

> **Comments:**
> **username_0**: Brilliant ! Thx a lot !  

---

### Answer by username_2 on 2024-07-08. Score: 1

I’m not sure if this is what you’re asking for, but you can number fetched entries inside a for loop in Twig using the current iteration of the loop (loop.index).
{% set entries = craft.entries.all() %}
{% for entry in entries %}
    Entry #{{ loop.index }} of {{ entries|length }}
{% endfor %}

To make this work when paginating entries, you can add the current page’s first entry number (pageInfo.first) to the zero-indexed iteration of the loop (loop.index0).
{% set entryQuery = craft.entries.limit(10) %}
{% paginate entryQuery as pageInfo, entries %}
{% for entry in entries %}
    Entry #{{ pageInfo.first + loop.index0 }} of {{ pageInfo.total }}
{% endfor %}

References:
https://craftcms.com/docs/5.x/development/element-queries.html#navigating-pages
https://twig.symfony.com/doc/3.x/tags/for.html#the-loop-variable

> **Comments:**
> **username_0**: ok, thx, will try and let you know  
> **username_0**: It works, but, for pagination state, for every next page, it starts from 1 of total, rather than continuing from the previous page.  
> **username_2**: You didn’t mention that in your question, but I’ve added a second code sample to my answer for the case when you’re paginating entries.  

---

