<p>Based on <a href="https://twitter.com/juban/status/1139207162159386625" rel="nofollow noreferrer">this clever tweet</a>, you can do this:</p>

<pre class="lang-twig prettyprint-override"><code>{% set allEntriesByDay = craft
  .entries()
  .section('stories')
  .orderBy('postDate DESC')
  .with(['categories'])
  .all() | group(e =&gt; e.postDate|date('long')) %}

{% set dataProvider = create({
  'class': 'yii\\data\\ArrayDataProvider',
  'allModels': allEntriesByDay,
  'pagination': {'pageSize': 3}}) %} {# Set the days per page here #}

{% set results = dataProvider.getModels() %}

{% set currentPage = dataProvider.getPagination().getPage() + 1 %}
{% set totalPages = dataProvider.getPagination().getPageCount() %}

{% if currentPage &gt; 1 %}
  {% set prevPage = currentPage - 1 %}
{% endif %}
{% if currentPage &lt; totalPages %}
  {% set nextPage = currentPage + 1 %}
{% endif %}

{% if results | length %}
  {% for day, entriesInDay in results %}
    &lt;h2&gt;{{ day }}&lt;/h2&gt;
    {% for entry in entriesInDay %}
      {{ entry.title }} &lt;br&gt;
    {% endfor %}
  {% endfor %}
  &lt;hr&gt;
  &lt;div&gt;
  {% if prevPage is defined %}
    &lt;a href="{{ url(craft.app.request.absoluteUrl, {'q': craft.app.request.get('q'), 'page': prevPage}) }}"&gt;&lt; Previous page&lt;/a&gt;
  {% endif %}

  {% if nextPage is defined %}
    &lt;a href="{{ url(craft.app.request.absoluteUrl, {'q': craft.app.request.get('q'), 'page': nextPage}) }}"&gt; - Next page &gt;&lt;/a&gt;
  {% endif %}
  &lt;/div&gt;
{% endif %}
</code></pre>

CC BY-SA 4.0
2020-03-09T15:42:43.537Z
Superb! Thanks Oli.
Ian Ebden
CC BY-SA 4.0
2020-03-09T15:47:51.503Z
I can't take the credit for this but thanks!
Oli
CC BY-SA 4.0
2020-03-09T14:31:06.157Z
2020-03-20T10:18:59.657Z
2020-03-20T10:18:59.657Z
Oli
<p>Been at this a couple of hours and my head is scrambled. Wonder if anyone has already solved it and cares to share? I'm trying to paginate a list of entries grouped by day - showing 3 days worth of entries on each page. This is slightly different (I think) to other threads on SE. Here's where I'm at so far:</p>

<pre><code>{% set allEntries = craft.entries.section('stories').with(['categories']).all() %}
{% set allEntriesByDay = allEntries|group(e =&gt; e.postDate|date('long')) %}
{% for day, entriesInDay in allEntriesByDay %}
    &lt;h2&gt;{{ day }}&lt;/h2&gt;
    {% for entry in entriesInDay %}
        ...
    {% endfor %}
{% endfor %}
{% include "_includes/pagination" ignore missing %}
</code></pre>

<pagination>
Paginate entries grouped by day
# Paginate entries grouped by day

(Asked by: username_0 on 2020-03-09)

Been at this a couple of hours and my head is scrambled. Wonder if anyone has already solved it and cares to share? I'm trying to paginate a list of entries grouped by day - showing 3 days worth of entries on each page. This is slightly different (I think) to other threads on SE. Here's where I'm at so far:
{% set allEntries = craft.entries.section('stories').with(['categories']).all() %}
{% set allEntriesByDay = allEntries|group(e => e.postDate|date('long')) %}
{% for day, entriesInDay in allEntriesByDay %}
    {{ day }}
    {% for entry in entriesInDay %}
        ...
    {% endfor %}
{% endfor %}
{% include "_includes/pagination" ignore missing %}

**Tags:** pagination


---

## 1 answers

### Answer by username_1 on 2020-03-09. Score: 2 | Accepted answer

Based on this clever tweet, you can do this:
{% set allEntriesByDay = craft
  .entries()
  .section('stories')
  .orderBy('postDate DESC')
  .with(['categories'])
  .all() | group(e => e.postDate|date('long')) %}

{% set dataProvider = create({
  'class': 'yii\\data\\ArrayDataProvider',
  'allModels': allEntriesByDay,
  'pagination': {'pageSize': 3}}) %} {# Set the days per page here #}

{% set results = dataProvider.getModels() %}

{% set currentPage = dataProvider.getPagination().getPage() + 1 %}
{% set totalPages = dataProvider.getPagination().getPageCount() %}

{% if currentPage > 1 %}
  {% set prevPage = currentPage - 1 %}
{% endif %}
{% if currentPage < totalPages %}
  {% set nextPage = currentPage + 1 %}
{% endif %}

{% if results | length %}
  {% for day, entriesInDay in results %}
    {{ day }}
    {% for entry in entriesInDay %}
      {{ entry.title }} 
    {% endfor %}
  {% endfor %}
  
  
  {% if prevPage is defined %}
    < Previous page
  {% endif %}

  {% if nextPage is defined %}
     - Next page >
  {% endif %}
  
{% endif %}

> **Comments:**
> **username_0**: Superb! Thanks username_1.  
> **username_1**: I can't take the credit for this but thanks!  

---

