I am working with a template in Craft 2, and I am setting up the criteria for entries to be displayed.
Here is my code (below).
{% set today = now|date('Y-m-d') %}
{% set criteria = {
section: 'bulletin',
order: 'postDate',
expiryDate: '>=' . today
} %}
{% set initialEntry = craft.entries(criteria).first() %}
{% set finalEntry = craft.entries(criteria).last() %}
I get this error:
Impossible to access an attribute ("today") on a string variable (">=").
How would I set expiryDate >= today?
~
is the concatenation operator! You can also use">= #{today}"
, which Twig refers to as "string interpolation." This looks fine, otherwise. 👍