1

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!

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

1 Answer 1

1

I ended up using this code.

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

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

Works for now anyway.

1
  • 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'.
    – a-am
    Sep 11, 2018 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.