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 have this piece of code which orders my entries by month, which is working great. I only have two issues which I can't work out. How would I display the year of the month beside the month title eg:

<h2>{{ month }} > {{ year }}</h2>

As the list could run over a number of years it would be good to distinguish this. The next part is I can't seem to convert the month from a number ie: 8 to the word ie. "august". When I filter it, it just returns "Jan".

{% set allEntries = craft.entries.section('featureArticles').find() %}
{% set allEntriesByMonth = allEntries|group('postDate.month') %}

{% for month, entriesInMonth in allEntriesByMonth %}

    <h2>{{ month }}</h2>

        {% for entry in entriesInMonth %}
            <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
        {% endfor %}

{% endfor %}
share|improve this question
up vote 3 down vote accepted

You're close!

We've got an example of how to do this here:

The trick is to group by year first, then by month. Using the 'F' token is how to tell PHP to display the name of the month.

share|improve this answer
Thanks Brad, this seems like it will do the trick. Can I still use the {{ year }} tag inside the month loop so it gives me August - 2014 as a title? – Daryl Campbell Aug 10 '14 at 16:43
Yup... will still work fine there. If that gets you what you want, mind marking this as the correct answer? – Brad Bell Aug 10 '14 at 17:17
this made my day! thanks a lot! – outline4 Sep 3 '14 at 9:17

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.