<p>You’re looking for the <a href="https://craftcms.com/docs/4.x/dev/tags.html#paginate" rel="nofollow noreferrer"><code>{% paginate %}</code> tag</a>!</p>
<p>This will take care of reading the &quot;page&quot; out of your URL, based on the <a href="https://craftcms.com/docs/4.x/config/general.html#pagetrigger" rel="nofollow noreferrer"><code>pageTrigger</code> config setting</a> and setting the query’s <code>offset</code>:</p>
<pre><code>{# Set up your query, but don't execute it: #}
{% set gamesQuery = craft.entries()
  .section('games')
  .limit(10) %}

{# Pass the query to the tag and let Craft handle setting the `offset`: #}
{% paginate gamesQuery as games, pageInfo %}

&lt;ul&gt;
  {% for game in games %}
    &lt;li&gt;{{ game.getLink() }}&lt;/li&gt;
  {% endfor %}
&lt;/ul&gt;
</code></pre>
<p>Note that <code>limit</code> here is still applied, and is responsible for setting the number of results per &quot;page.&quot;</p>
<p>Check out the official documentation (linked above) for more info—and to learn about outputting links to other pages of results!</p>
<hr />
<p>To answer your second question more directly: Yes—element queries also support the <code>.offset()</code> param, which will return results beginning at that index. Combined with <code>.limit()</code>, you can effectively select a range of elements, where <code>offset</code> is the start and <code>offset + limit</code> (pseudo-code) is the end. This is what makes the paginate tag work, under the hood—but you don't need to worry about the minutiae. </p>

CC BY-SA 4.0
2022-11-22T18:28:15.540Z
2022-11-22T18:28:15.540Z
August Miller
<p>Who can tell me how to create a pager on craft CMS.
How would I implement this:</p>
<pre><code>{% set games = craft.entries().section('games').limit(10).all() %}
</code></pre>
<p>I was thinking of getting the page number from the URL. By dividing the total number of elements by the number of output elements, determine the number of pages. Well, using .limit() to output the elements of the requested page, for example:</p>
<pre><code>{% set games = craft.entries().section('games').limit(10,20).all() %}
</code></pre>
<p>But as I understand it, only one number is specified in .limit() and that's it.
Is there a method in Craft CMS that allows you to output limited entries in the &quot;FROM - TO&quot; model? Maybe it would help me a lot</p>

<craft3>
How to create pager of elements
# How to create pager of elements

(Asked by: username_0 on 2022-11-22)

Who can tell me how to create a pager on craft CMS.
How would I implement this:
{% set games = craft.entries().section('games').limit(10).all() %}

I was thinking of getting the page number from the URL. By dividing the total number of elements by the number of output elements, determine the number of pages. Well, using .limit() to output the elements of the requested page, for example:
{% set games = craft.entries().section('games').limit(10,20).all() %}

But as I understand it, only one number is specified in .limit() and that's it.
Is there a method in Craft CMS that allows you to output limited entries in the "FROM - TO" model? Maybe it would help me a lot

**Tags:** craft3

---

## 1 answers

### Answer by username_1 on 2022-11-22. Score: 3 | Accepted answer

You’re looking for the {% paginate %} tag!
This will take care of reading the "page" out of your URL, based on the pageTrigger config setting and setting the query’s offset:
{# Set up your query, but don't execute it: #}
{% set gamesQuery = craft.entries()
  .section('games')
  .limit(10) %}

{# Pass the query to the tag and let Craft handle setting the `offset`: #}
{% paginate gamesQuery as games, pageInfo %}


  {% for game in games %}
    {{ game.getLink() }}
  {% endfor %}


Note that limit here is still applied, and is responsible for setting the number of results per "page."
Check out the official documentation (linked above) for more info—and to learn about outputting links to other pages of results!

To answer your second question more directly: Yes—element queries also support the .offset() param, which will return results beginning at that index. Combined with .limit(), you can effectively select a range of elements, where offset is the start and offset + limit (pseudo-code) is the end. This is what makes the paginate tag work, under the hood—but you don't need to worry about the minutiae.


---

