Trying to create an archive page for each of my blog types within Craft. The page sorts by year and by month. (year
and month
are coming from my routes in this code.)
By using the following, I can print out each month with posts and the number of posts the month has. My problem is that I also need to print out the months with no post count and can't seem to figure out how to do that.
{% set entriesInYear = craft.entries.section('pressReleases').limit(null).after(year).before(year+1) %}
{% for month, entries in entriesInYear | group("postDate|date('F')") %}
<li><a href="#">{{ month }} ({{ entries|length }})</a></li>
{% endfor %}
That will yield me a printout of:
- April (7)
- March (4)
- February (1)
I just need to also print out all the months in between with a (0)
indicator.