List only those months that have entries I setup my archive using the Craft demo.  I have a page for each year.

I use MixItUp,(think Isotope) to allow a user to filter entries by month. There are simple hard coded buttons for each month.

How can I loop through the entries and create a button for only those months that have entries?   

Update.  I have a loop that pulls all the entries for a given year.  I then use MixItUp (think Isotope) to filter the entries by month.  

There is a button for each month that triggers MixItUp.  I want to make the creation of these buttons dynamic.  That is, I want to create a loop that generates a button for only those months that contain entries and create a class with the month's name that corresponds with the month in the class names of the entry cards.

For any given year, the loop would create 1-12 buttons.

{% for month that has &gt; 0 entries %}

&lt;button type="button" class="btn btn-outline-secondary btn-lg"   data-mixitup-control data-filter=".February"&gt;Feb&lt;/button&gt;

{% endfor %}




Thanks
{% set date = (date()).modify('first day of january 00:00:00') %}
{% for month in 1..12 %}
    {% set endOfMonth = clone(date).modify('last day of this month') %}
        {% set exists= craft.entries
            .postDate(['and', '&gt;=' ~ date.format('-.m-d H:i:s'), '&lt;=' ~ endOfMonth.format('Y-m-d H:i:s') ])
            .exists()
        %}

    {% do date.modify('first day of next month') %}
{% endfor %}


loop all months and check if there are entries in this month or not