I need to display entries from the past 12 months. I'd like to create an entry query and set the timeframe of the entries I need.


I used the after parameter in my query.

{% set query = craft.entries({
    after: now|date_modify('5:00 -12 months')
}).all() %}

I'm grabbing todays date, then modifying with the date_modify filter. The 5:00 string makes sure it changes at the same time everyday.

I got the usage of date_modify from carlcs's answer here: How to only show entries older than 12 months

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.