I've a list of entries, all with custom dates. Is there a way to show entries from a specific year, just using the custom date rather than the posted date?

Any help is much appreciated!

  • Are "custom dates" dates from a Date/Time custom field on the entries?
    – Brad Bell
    Sep 6 '18 at 23:06
  • They are - sorry, should have been a bit clearer.
    – Redbloc
    Sep 8 '18 at 10:29

I ended up using this code.

{% set upcoming = craft.entries.section('section').order('customDate')%}            

{% for entry in upcoming %} 
    {% if entry.customDate =='2018-10-12' %}    
    {% endif %}
{% endfor %}

Works for now anyway.

  • if you want a specific year not just a specific day of the year you can do something like this entry.customDate|date('Y') == '2018'.
    – aran
    Sep 11 '18 at 2:16

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.