<p>Instead of using pagination, you might try creating a custom route using tags for year/month/day. Those tags will be available as variables in the template that you can use to load that days entries and generate the nav for next/previous day, etc. Using ajax the uri won't be visible to the user anyway.</p>

<pre><code>{% set postDate = year ~ '-' ~ month ~ '-' ~ day %}
{% set nextDate = postdate|date_modify('+1 day')) %}
{% set previousDate = postdate|date_modify('-1 day')) %}

{% set entries = craft.entries.postDate('and', '&gt;= ' ~ postdate, '&lt; ' ~ nextDate %}

{% for entry in entries %}
    {{ entry.title }}
    ...
{% endfor %}

&lt;div class="pagination"&gt;
    &lt;a href="{{ 'section/' ~ nextDate|date("Y/m/d") }}"&gt;next&lt;/a&gt;
    &lt;a href="{{ 'section/' ~ previousDate|date("Y/m/d") }} "&gt;previous&lt;/a&gt;
&lt;/div&gt;
</code></pre>

<p>Not tested, but should be close. You'll need to modify the links to work with your ajax of course.</p>

CC BY-SA 3.0
2015-01-04T19:22:50.987Z
2015-01-05T02:47:58.893Z
2015-01-05T02:47:58.893Z
Douglas McDonald
<p>This is giving me a surprisingly hard time. Has anyone tried to paginate entries by date, in this case, specifically by day; i.e.: First page loads today's posts, next page loads yesterday's, then the day before yesterday, etc.</p>

<p>I tried grouping items by date, as done in the archive page example, and then paginating the groups but it didn't work.</p>

<p>In this case I am using a combination of pagination + ajax to load more content when needed. However the needs of the project have changed, and paginating by number of items isn't the best approach. It'd be better to show content based on the date.</p>

<p>Anyone?</p>

<entries><pagination><group>
Paginate Entries by Day
# Paginate Entries by Day

(Asked by: username_0 on 2015-01-04)

This is giving me a surprisingly hard time. Has anyone tried to paginate entries by date, in this case, specifically by day; i.e.: First page loads today's posts, next page loads yesterday's, then the day before yesterday, etc.

I tried grouping items by date, as done in the archive page example, and then paginating the groups but it didn't work.

In this case I am using a combination of pagination + ajax to load more content when needed. However the needs of the project have changed, and paginating by number of items isn't the best approach. It'd be better to show content based on the date.

Anyone?

**Tags:** entries, pagination, group

---

## 1 answers

### Answer by username_1 on 2015-01-04. Score: 4 | Accepted answer

Instead of using pagination, you might try creating a custom route using tags for year/month/day. Those tags will be available as variables in the template that you can use to load that days entries and generate the nav for next/previous day, etc. Using ajax the uri won't be visible to the user anyway.
{% set postDate = year ~ '-' ~ month ~ '-' ~ day %}
{% set nextDate = postdate|date_modify('+1 day')) %}
{% set previousDate = postdate|date_modify('-1 day')) %}

{% set entries = craft.entries.postDate('and', '>= ' ~ postdate, '< ' ~ nextDate %}

{% for entry in entries %}
    {{ entry.title }}
    ...
{% endfor %}


    next
    previous


Not tested, but should be close. You'll need to modify the links to work with your ajax of course.


---

