Webflow sync, pageviews & more.
NEW

How can I filter dynamic lists in Webflow using a start date of "Today" to create automatically updating lists and pages based on date-sensitive content?

TL;DR
  • Add a date field (e.g., "Start Date") to your CMS collection and bind a Collection List to show all items without native filters.
  • Assign classes to items and date elements, then use JavaScript to compare each item's date to today's and hide past entries dynamically.

To filter dynamic lists in Webflow based on a start date of “Today,” you need to combine Webflow’s native CMS filters with custom JavaScript, as Webflow does not support “today’s date” filtering natively.

1. Set Up Your CMS with a Start Date Field

  • Go to your CMS Collection and make sure it has a Date field (e.g., “Start Date”) for your time-sensitive items.
  • Ensure this date field reflects the content’s publish, event, or valid start time.

2. Design Your Collection List on the Page

  • On your page (static or CMS template), add a Collection List and bind it to this CMS Collection.
  • Show all relevant items—do not apply a CMS filter yet based on the date.

3. Add a Unique Class to Filter Targets

  • Give the Collection List Wrapper an identifiable class like event-list.
  • Add a class (e.g., event-item) to each collection item or wrap the date element inside a span or div with a custom class like start-date.

4. Write JavaScript to Filter by Today’s Date

  • Embed custom code using the Page Settings > Before custom code area, or in an Embed element.
  • Use JavaScript to:
  • Capture today’s date.
  • Loop through each collection item.
  • Extract its date from the .start-date element.
  • Hide any items whose date is older than today.

5. Use ISO Format or Unix Timestamps if Possible

  • For easier comparison, format your CMS date as YYYY-MM-DD or add data- attributes with timestamps for parsing.
  • Example: store the date in a span like <span class="start-date" data-date="2024-06-12"></span>.

6. Example of What the Script Might Do (Without Code Tags)

  • The script reads all .start-date[data-date] elements.
  • Compares each one against the current date.
  • Hides the parent .event-item if the date is in the past.

7. Optional: Use CMS Sorting to Order Future Events

  • In the Collection List settings, sort by Start Date → Ascending so upcoming events appear first.
  • This works natively even if filtering itself is JS-based.

Summary

Webflow’s CMS doesn't natively support "Today" as a filter value, but you can simulate real-time filtering by using JavaScript to compare each item’s date with today’s date and hide outdated ones. This creates automatically updating, date-sensitive lists.

Rate this answer

Other Webflow Questions