Hi friends, on calendar pages: is it possible to template request for upcoming events by year, say, get events only for 2018?
Hi Jedd! This is definitely possible. In the Template for your calendar page, you'll notice a couple 'forloops' that are responsible for scanning through all of your upcoming events and displaying the same type of details for each one (i.e. Event name, location, date, etc..). It'll look like this:
{% for event in page.calendar.events_upcoming %}
<li>{% include "event" %}</li>
{% endfor %}
However, you can add an "IF/THEN" statement in there using liquid, having it examine the event "start at" date, like so:
{% for event in page.calendar.events_upcoming %}
{% capture eventyear %}{{ event.local_start_at | date: '%Y' }}{% endcapture %}
{% if eventyear == "2018" %}
<li>{% include "event" %}</li>
{% endif %}
{% endfor %}
Let me know if you run into any problems adding this to your calendar page!
Showing 3 reactions
Sign in with
Certified Developer