1

A project I'm working on needs to show a daily reading depending on the date you access the page. I plan to create entries for each day of the year, and each year it will show the post for that day.

For example, I'll create an entry with a post date of May 1, 2015. That entry should show on May 1, 2016/2017/2018, etc.

I've tried only putting in MM-DD in the postDate parameter, but no luck; that throws a PHP error. Any ideas?

1 Answer 1

1

I fear this is not possible with a simple postDate parameter and you have to find a workaround. The Twig apporach would be to loop all events and filter the right ones with a simple conditional.

{% set events = craft.entries.section('events').limit(null).order('postDate asc') %}
{% for event in events %}
    {% if event.postDate|date('m-d') == now|date('m-d') %}
        ...
    {% endif %}
{% endfor %}

If you'd like to paginate the results, collect / merge entry IDs within the for loop first and then prepare another ElementCriteriaModel with these IDs in its id param, to get the entries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.