<p>According to your code, I think the issue is that you loop through <code>entries</code> instead of <code>pageEntries</code>.</p>
<pre><code>&lt;!-- Just set this query once. Rest is done by the paginate tag --&gt;
{% set entries = craft.entries.section(sectionName) 
    .orderBy('postDate DESC')
    .relatedTo(relatedElement)
    .with ( ['thumbnail'] )
    .limit(10)
%}

&lt;!-- here you set the paginate query. Use pageInfo for infos of the current page, the pageEntries gives you an object that contains the entries of the current page. So instead of &quot;for entry in entries&quot; you use &quot;for entry in pageEntries&quot; --&gt;
{% paginate entries as pageInfo, pageEntries %}

&lt;!-- Your pagination as it is, looks fine --&gt;
{% if pageInfo.totalPages &gt; 1 %}
  &lt;div class=&quot;pagination&quot;&gt;
    ...
  &lt;/div&gt;  
{% endif %}

&lt;!-- here you should loop through the entries you set in the paginate tag instead of a second query. Use the pageEntries (from {% paginate %}) object instead of entries, to show the entries for this page. --&gt;
{% for item in pageEntries %}
  &lt;p&gt;{{ item.teaser }}&lt;/p&gt;
{% endfor %}
</code></pre>

CC BY-SA 4.0
2022-06-13T19:03:02.420Z
That was it! Thanks so much.
4midori
CC BY-SA 4.0
2022-06-12T07:04:32.120Z
2022-06-12T07:04:32.120Z
Max Strebel
<p>Craft is no longer handling my pagination properly. This follows an update from somewhere around 3.4 to 3.7.X.</p>
<pre><code>{% set entries = craft.entries.section(sectionName) 
    .orderBy('postDate DESC')
    .relatedTo(relatedElement)
    .with ( ['thumbnail'] )
    .limit(10)
    %}
</code></pre>
<p><strong>sectionName</strong> and <strong>relatedElement</strong> are set earlier in the template. I'm getting correct URLs, like:</p>
<ul>
<li>/blog/category/rens-nrens/</li>
<li>/blog/category/rens-nrens/p2
and the route I have set up is working, but Craft keeps showing me the first page of results.</li>
</ul>
<p><code>{% paginate entries as pageInfo, pageEntries %}</code></p>
<p><code>...</code></p>
<pre><code>{% if pageInfo.totalPages &gt; 1 %}
&lt;div class=&quot;pagination&quot;&gt;
More:
&lt;a href=&quot;{{ pageInfo.firstUrl }}&quot; title=&quot;First page of news&quot;&gt;First&lt;/a&gt;
{% for page, url in pageInfo.getPrevUrls(3) %}
  &lt;a href=&quot;{{ url }}&quot;&gt;{{ page }}&lt;/a&gt;
{% endfor %}

&lt;span class=&quot;active&quot;&gt;{{ pageInfo.currentPage }}&lt;/span&gt;

{% for page, url in pageInfo.getNextUrls(3) %}
  &lt;a href=&quot;{{ url }}&quot;&gt;{{ page }}&lt;/a&gt;
{% endfor %}
&lt;a href=&quot;{{ pageInfo.lastUrl }}&quot; title=&quot;Last page of news&quot;&gt;Last&lt;/a&gt;
&lt;/div&gt;  
{% endif %} 
</code></pre>
<p>...</p>
<pre><code>{% set entries = craft.entries.section(sectionName) 
.orderBy('postDate DESC')
.relatedTo(relatedElement)
.with ( ['thumbnail'] )
.limit(10)
%}

{% for item in entries %}
various other bits...
  &lt;p&gt;{{ item.teaser }}&lt;/p&gt;

{% endfor %}
</code></pre>
<p>{% paginate entries as pageInfo, pageEntries %}</p>

CC BY-SA 4.0
2022-06-09T07:21:09.717Z
Can you show the code you use to output the entries? Do you use the `{% paginate entries as pageInfo, pageEntries %}` tag?
Max Strebel
CC BY-SA 4.0
2022-06-09T19:52:20.413Z
@MaxStrebel Yes. I just updated my post with the code.
4midori
CC BY-SA 4.0
2022-06-09T20:39:08.447Z
Thanks for updating. But where do you actually output the posts? I'm missing a `{% for entry in pageEntries %} ... {% endfor %}`which actually outputs the entries. what you show is just the pagination, right? On another note: did you try to explicitly set `pageTrigger` in the general config settings? https://craftcms.com/docs/3.x/config/config-settings.html#pagetrigger
Max Strebel
CC BY-SA 4.0
2022-06-10T17:29:21.440Z
@MaxStrebel I updated the code further, above. I did not set pageTrigger, because I am letting Craft apply its defaults.
4midori
CC BY-SA 4.0
2022-06-12T07:05:28.817Z
Hey 4midori, thanks for the additional code. I answered with a solution hopefully. On your last comment: while it is good to trust on defaults, you might just want to check once if setting the (`pageTrigger`) parameter explicitly maybe fixes it. In this case thats not the problem, just a thought.
Max Strebel
<routes><pagination>
Pagination breaking following update to Craft 3.7.X
# Pagination breaking following update to Craft 3.7.X

(Asked by: username_0 on 2022-06-08)

Craft is no longer handling my pagination properly. This follows an update from somewhere around 3.4 to 3.7.X.
{% set entries = craft.entries.section(sectionName) 
    .orderBy('postDate DESC')
    .relatedTo(relatedElement)
    .with ( ['thumbnail'] )
    .limit(10)
    %}

sectionName and relatedElement are set earlier in the template. I'm getting correct URLs, like:

/blog/category/rens-nrens/
/blog/category/rens-nrens/p2
and the route I have set up is working, but Craft keeps showing me the first page of results.

{% paginate entries as pageInfo, pageEntries %}
...
{% if pageInfo.totalPages > 1 %}

More:
First
{% for page, url in pageInfo.getPrevUrls(3) %}
  {{ page }}
{% endfor %}

{{ pageInfo.currentPage }}

{% for page, url in pageInfo.getNextUrls(3) %}
  {{ page }}
{% endfor %}
Last
  
{% endif %} 

...
{% set entries = craft.entries.section(sectionName) 
.orderBy('postDate DESC')
.relatedTo(relatedElement)
.with ( ['thumbnail'] )
.limit(10)
%}

{% for item in entries %}
various other bits...
  {{ item.teaser }}

{% endfor %}

{% paginate entries as pageInfo, pageEntries %}

**Tags:** routes, pagination
> **Comments:**
> **username_1**: Can you show the code you use to output the entries? Do you use the `{% paginate entries as pageInfo, pageEntries %}` tag?  
> **username_0**: @MaxStrebel Yes. I just updated my post with the code.  
> **username_1**: Thanks for updating. But where do you actually output the posts? I'm missing a `{% for entry in pageEntries %} ... {% endfor %}`which actually outputs the entries. what you show is just the pagination, right? On another note: did you try to explicitly set `pageTrigger` in the general config settings? https://craftcms.com/docs/3.x/config/config-settings.html#pagetrigger  
> **username_0**: @MaxStrebel I updated the code further, above. I did not set pageTrigger, because I am letting Craft apply its defaults.  
> **username_1**: Hey 4midori, thanks for the additional code. I answered with a solution hopefully. On your last comment: while it is good to trust on defaults, you might just want to check once if setting the (`pageTrigger`) parameter explicitly maybe fixes it. In this case thats not the problem, just a thought.  

---

## 1 answers

### Answer by username_1 on 2022-06-12. Score: 2 | Accepted answer

According to your code, I think the issue is that you loop through entries instead of pageEntries.

{% set entries = craft.entries.section(sectionName) 
    .orderBy('postDate DESC')
    .relatedTo(relatedElement)
    .with ( ['thumbnail'] )
    .limit(10)
%}


{% paginate entries as pageInfo, pageEntries %}


{% if pageInfo.totalPages > 1 %}
  
    ...
    
{% endif %}


{% for item in pageEntries %}
  {{ item.teaser }}
{% endfor %}

> **Comments:**
> **username_0**: That was it! Thanks so much.  

---

