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

1 Answer 1


You're close!

We've got an example of how to do this here: http://buildwithcraft.com/help/entry-archive#grouping-by-year-and-then-month

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.

  • 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? Aug 10, 2014 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, 2014 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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