Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T15:42:43.537Z
Answers.Text: Superb! Thanks Oli.
Answers.UserDisplayName: Ian Ebden
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T15:47:51.503Z
Answers.Text: I can't take the credit for this but thanks!
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T14:31:06.157Z
Answers.LastActivityDate: 2020-03-20T10:18:59.657Z
Answers.LastEditDate: 2020-03-20T10:18:59.657Z
Answers.UserDisplayName: Oli
Body: <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>
  
Tags: <pagination>
Title: Paginate entries grouped by day
ThreadText: # 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 %}
      <h2>{{ day }}</h2>
      {% 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](https://twitter.com/juban/status/1139207162159386625), you can do this:
  
  ```twig
  {% 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 %}
      <h2>{{ day }}</h2>
      {% for entry in entriesInDay %}
        {{ entry.title }} <br>
      {% endfor %}
    {% endfor %}
    <hr>
    <div>
    {% if prevPage is defined %}
      <a href="{{ url(craft.app.request.absoluteUrl, {'q': craft.app.request.get('q'), 'page': prevPage}) }}">< Previous page</a>
    {% endif %}
  
    {% if nextPage is defined %}
      <a href="{{ url(craft.app.request.absoluteUrl, {'q': craft.app.request.get('q'), 'page': nextPage}) }}"> - Next page ></a>
    {% endif %}
    </div>
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Superb! Thanks Oli.  
  > **username_1**: I can't take the credit for this but thanks!  
  
  ---
  
  