I’m having trouble with
Filter events on my live ‘list’ page by their date field.
Working in
Wix Studio CMS
Site link
What I’m trying to do
I want events to stop displaying on the live site once their date has past - without me having to check and manually delete or hide every day.
What I’ve tried so far
-
the obvious: filter my dataset by Event Date, but the only options for filtering that field are ‘empty’ and ‘not empty’
-
some code suggestions from Gemini - here’s the last one:
import wixData from ‘wix-data’; $w.onReady(function () { // Get yesterday’s date let yesterday = new Date(); yesterday.setDate(yesterday.getDate() - 1); yesterday.setHours(0, 0, 0, 0); // Filter both datasets with the 1-day grace period // We use .gt (Greater Than) yesterday $w(“#dataset1”).setFilter(wixData.filter().gt(“eventDate”, yesterday)); // We wrap the dynamic one in a ‘catch’ so if it errors, it doesn’t break the whole page $w(“#dynamicDataset”).setFilter(wixData.filter().gt(“eventDate”, yesterday)) .catch((err) => { console.log(“Dynamic dataset filter skipped due to URL error, but slider should work.”); }); });Gemini had a few code suggestions, but none of them worked.
-
Adding a boolean ‘expired field’ and setting an automation to go to the collection, check the date, and mark the event expired if the date has passed (then filter the repeater with that field). The ‘Update item’ action repeatedly gives an error message as soom as I select my Upcoming Events collection. (as a test, I tried, the ‘Find item’ action - this one did allow me to choose the Upcoming Events collection … but that doesn’t help me.
-
I feel like this should be relatively easy and I’m missing something obvious, but I cannot for the life of me figure out what it is. Help??
Extra context
Anything else that might help - edge cases, screenshots, etc.
