<p>This seems like a good use case for Craft's <code>group</code> filter. I'd recommend reading <a href="https://craftcms.com/support/entry-archive" rel="nofollow noreferrer">this page</a> to get a better understanding of how it's used. </p>

<p>Not quite sure what your code looks like but I'll pull this from the above mentioned support article for explanation purposes: </p>

<pre><code>{% set allEntries = craft.entries.section('blog').limit(null) %}

{% for month, entries in allEntries | group("postDate|date('F')") %}
    &lt;h3&gt;{{ month }}&lt;/h3&gt;
    &lt;ul&gt;
        {% for entry in entries %}
            &lt;li&gt;{{ entry.getLink() }}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}
</code></pre>

<p>So obviously you'd need to adapt this code to your setup, for example, switch out the month grouping for a per-day grouping. Then what I would do is wrap it in a conditional that only works if the postDate is more than three days older than today's date. Then you could use a similar query as the above to display the first three sections individually, (i.e. one for "Today", one for "Yesterday", and one for the day of the week of the third day).</p>

<p>Might not be the best way (curious to see any other answers that might show up), but just the first thought that came to mind from a quick perusal of your question.</p>

CC BY-SA 3.0
2018-04-03T08:48:45.570Z
Hi Jalen, thanks very much for the help! It's definitely the way I was thinking but having numerous code snippets for multiple days seems a bit clunky? I may have a dig around and see what I can do
JMKelley
CC BY-SA 3.0
2018-04-03T12:27:47.337Z
Yeah I guess it sounds a bit clunky. If you do go this route, I would recommend maybe eager-loading your entries to improve performance and reduce the number of database queries.
Jalen Davenport
CC BY-SA 3.0
2018-04-03T01:12:42.997Z
2018-04-03T01:12:42.997Z
Jalen Davenport
<p>I've been looking around at numerous posts but can't seem to find a solution that works without constant work arounds. I'm looking to show posts split by days they were posted similar to www.producthunt.com</p>

<p>Today, Yesterday -> Sunday. Then displaying the date posted e.g. 31st March from then on.</p>

<p>Different to most questions as this is showing live posts set out by different worded days instead of numerical. I can't seem to find a way of doing this without repeating the same code block for 7 days then a generic by date loop?</p>

<p>Is this possible in Craft?</p>

CC BY-SA 3.0
2018-04-03T00:38:43.243Z
Possible duplicate of [How to show entries which are live between dates regardless of postdate or expiry dates?](https://craftcms.stackexchange.com/questions/8992/how-to-show-entries-which-are-live-between-dates-regardless-of-postdate-or-expir) see how to calculate time https://stackoverflow.com/questions/10197900/given-a-unix-timestamp-how-to-get-beginning-and-end-of-that-day
Robin Schambach
CC BY-SA 3.0
2018-04-03T08:51:51.293Z
Hey Robin! It's a bit different as that's just looking for a numerical loop rather than one by worded day :) I've edited the question to be more targeted.
JMKelley
CC BY-SA 3.0
2018-04-03T08:56:28.737Z
Alright, I've removed the vote for closing. Otherwise your solution would be exactly that: loop through the days / date distances and use the method provided in the link. You don't need the same block 7 times, you can create a loop for it
Robin Schambach
<templating><entries>
Split posts by days similar to Product hunt
# Split posts by days similar to Product hunt

(Asked by: username_0 on 2018-04-02)

I've been looking around at numerous posts but can't seem to find a solution that works without constant work arounds. I'm looking to show posts split by days they were posted similar to www.producthunt.com

Today, Yesterday -> Sunday. Then displaying the date posted e.g. 31st March from then on.

Different to most questions as this is showing live posts set out by different worded days instead of numerical. I can't seem to find a way of doing this without repeating the same code block for 7 days then a generic by date loop?

Is this possible in Craft?

**Tags:** templating, entries
> **Comments:**
> **username_1**: Possible duplicate of [How to show entries which are live between dates regardless of postdate or expiry dates?](https://craftcms.stackexchange.com/questions/8992/how-to-show-entries-which-are-live-between-dates-regardless-of-postdate-or-expir) see how to calculate time https://stackoverflow.com/questions/10197900/given-a-unix-timestamp-how-to-get-beginning-and-end-of-that-day  
> **username_0**: Hey Robin! It's a bit different as that's just looking for a numerical loop rather than one by worded day :) I've edited the question to be more targeted.  
> **username_1**: Alright, I've removed the vote for closing. Otherwise your solution would be exactly that: loop through the days / date distances and use the method provided in the link. You don't need the same block 7 times, you can create a loop for it  

---

## 1 answers

### Answer by username_2 on 2018-04-03. Score: 2 | Accepted answer

This seems like a good use case for Craft's group filter. I'd recommend reading this page to get a better understanding of how it's used. 
Not quite sure what your code looks like but I'll pull this from the above mentioned support article for explanation purposes: 
{% set allEntries = craft.entries.section('blog').limit(null) %}

{% for month, entries in allEntries | group("postDate|date('F')") %}
    {{ month }}
    
        {% for entry in entries %}
            {{ entry.getLink() }}
        {% endfor %}
    
{% endfor %}

So obviously you'd need to adapt this code to your setup, for example, switch out the month grouping for a per-day grouping. Then what I would do is wrap it in a conditional that only works if the postDate is more than three days older than today's date. Then you could use a similar query as the above to display the first three sections individually, (i.e. one for "Today", one for "Yesterday", and one for the day of the week of the third day).
Might not be the best way (curious to see any other answers that might show up), but just the first thought that came to mind from a quick perusal of your question.

> **Comments:**
> **username_0**: Hi Jalen, thanks very much for the help! It's definitely the way I was thinking but having numerous code snippets for multiple days seems a bit clunky? I may have a dig around and see what I can do  
> **username_2**: Yeah I guess it sounds a bit clunky. If you do go this route, I would recommend maybe eager-loading your entries to improve performance and reduce the number of database queries.  

---

