2

I’m trying to show only entries for the created in the last month. I’ve taken this from the example in the docs but it ends up showing nothing. There’s 100% entries with a postDate in the last month.

What am I missing?

{% set start = now|date_modify("-1 month")|date('Y-m-d') %}
{% set end = now|date('Y-m-d') %}

{% set newsQuery = craft.entries({
    section: 'news',
    postDate: ['and', ">= #{start}", "< #{end}"],
}) %}

Thanks!

4

Immediately found a solution!

{% set newsQuery = craft.entries({
    section: 'news',
    after: now|date_modify('0:00 -1 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.