Paginate entries grouped by day 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 =&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 %}
Based on this clever tweet, you can do this:

{% 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 %}