Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wondering how I would replicate the ExpressionEngine date_heading tag pair in Craft?

{date_heading}  {entry_date format="%Y %m %d"}  {/date_heading}

The date heading can be used to show a heading at certain intervals. The interval can be set to show hourly, daily, weekly, monthly, or yearly.

share|improve this question
Could you clarify the ultimate goal here? Is it to show entries grouped by dates? – Stuart Whitehead Jun 21 '14 at 14:50
Yep... that's exactly what I'd like to do. – Jesse Bennett-Chamberlain Jun 21 '14 at 15:02
up vote 7 down vote accepted


Take a look at Craft's custom group filter. Your example could look like this:

{% set allEntries = craft.entries.section('blog').find() %}
{% set allEntriesByDay = allEntries | group('postDate') %}

{% for day, entriesInDay in allEntriesByDay %}
    <h1>{{ day }}</h1>

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



You could also save the last entries date and use conditionals:

{% set allEntries = craft.entries.section('blog') %}
{% set last_date = '' %}

{% for entry in allEntries %}
    {% if last_date < %}
        This entry is the first of a new day
    {% endif %}

    {% set last_date = %}

    {{ entry.title }}
{% endfor %}
share|improve this answer
This might be a dumb question... but how do I reformat the {{ day }} variable in your first example? If I do something like: {{ day|date("D") }} It changes every instance to the same date. – Jesse Bennett-Chamberlain Jun 21 '14 at 16:29
@JesseBennett-Chamberlain You're right, my mistake. I accidentally added .day to postDate which means only the numerical value was passed. I edited the answer, it works now. – Victor In Jun 21 '14 at 16:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.