<p>Try this:</p>

<pre><code>{% set year = craft.request.segment(4) %}
{% set month = craft.request.segment(5) %}

{% set entriesInYear = craft.entries.section('bulletinOnline').limit(null).after(year).before(year+1) %}
{% set groupedEntries =  entriesInYear | group("postDate|date('m')") %}

{% for year, entriesInYear in allEntries | group("postDate.year") %}
    {% for month, entries in entriesInYear | group("postDate|date('m')") %}

        &lt;a href="{{ url('/archive/')}}/{{ year }}/{{ month }}"&gt;
        {{ month |date((year + 1) ~ '-' ~ month ~ '-01')|date('M') }}&amp;nbsp;({{ entries|length }})&lt;/a&gt;
    {% endfor %}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2019-05-03T00:42:28.497Z
2019-05-03T00:42:28.497Z
Brad Bell
<p>I'm trying to figure out how I can print the month name i.e April in the below. Currently, it's printing the last three months that contain entries.</p>

<pre><code>{% set year = craft.request.segment(4) %}
{% set month = craft.request.segment(5) %}

{% set entriesInYear = craft.entries.section('bulletinOnline').limit(null).after(year).before(year+1) %}
{% set groupedEntries =  entriesInYear | group("postDate|date('m')") %}

{% for year, entriesInYear in allEntries | group("postDate.year") %}
    {% set counter = ( counter | default(0) ) + 1 %}

    {% for month, entries in entriesInYear | group("postDate|date('m')") %}

        &lt;a href="{{ url('/archive/')}}/{{ year }}/{{ month }}"&gt;
            {% for monthWord, entries in entriesInYear|group("postDate|date('F')") %}
                {{ monthWord }}
            {% endfor %}
            &amp;nbsp;({{ entries|length }})
        &lt;/a&gt;
    {% endfor %}
{% endfor %}
</code></pre>

<p>Example output:</p>

<pre><code>&lt;a href="'/archive/2019/04/"&gt;MarchAprilMay(2)&lt;/a&gt;
</code></pre>

<datetime><postdate><archives>
Displaying a month name in an archive
# Displaying a month name in an archive

(Asked by: username_0 on 2019-05-02)

I'm trying to figure out how I can print the month name i.e April in the below. Currently, it's printing the last three months that contain entries.
{% set year = craft.request.segment(4) %}
{% set month = craft.request.segment(5) %}

{% set entriesInYear = craft.entries.section('bulletinOnline').limit(null).after(year).before(year+1) %}
{% set groupedEntries =  entriesInYear | group("postDate|date('m')") %}

{% for year, entriesInYear in allEntries | group("postDate.year") %}
    {% set counter = ( counter | default(0) ) + 1 %}

    {% for month, entries in entriesInYear | group("postDate|date('m')") %}

        
            {% for monthWord, entries in entriesInYear|group("postDate|date('F')") %}
                {{ monthWord }}
            {% endfor %}
             ({{ entries|length }})
        
    {% endfor %}
{% endfor %}

Example output:
MarchAprilMay(2)

**Tags:** datetime, postdate, archives

---

## 1 answers

### Answer by username_1 on 2019-05-03. Score: 1 | Accepted answer

Try this:
{% set year = craft.request.segment(4) %}
{% set month = craft.request.segment(5) %}

{% set entriesInYear = craft.entries.section('bulletinOnline').limit(null).after(year).before(year+1) %}
{% set groupedEntries =  entriesInYear | group("postDate|date('m')") %}

{% for year, entriesInYear in allEntries | group("postDate.year") %}
    {% for month, entries in entriesInYear | group("postDate|date('m')") %}

        
        {{ month |date((year + 1) ~ '-' ~ month ~ '-01')|date('M') }} ({{ entries|length }})
    {% endfor %}
{% endfor %}


---

