Filter cms items on current day


I’m building a site for a radio station and I want to create a schedule for the current day.

My solution is to get the data from the collection “Programs” where I have inserted an option field with numbers 0 - 6 for each day of the week. I have then put embedded code component inside the cms item and pulling the data dynamically from the option field in the programs collection by adding field from cms.

This is my code

             .noresults {display: none;}


            const date = new Date();
            const today = date.getDay();

            if (Day != today) {
              } else {


Unfortunately I cant get it to work.
Here’s the read-only link

Can you share a link to the published version so we can see the code running? Also you can create filter for the current date natively in Webflow if you use a date/time field in your collection.

Yes I have tried the date/time method in webflow but I don’t think it will work on recurring events without changing the date manually. If it’s possible please share how because I’d rather do it natively in webflow.

Here’s the link to the published site.

Your published site code doesn’t reflect what you posted here. You have a script section with the first 2 lines and then end script and then another section with more code later which throws a Syntax Error so you need to fix that.
To set a today filter you can do something like this screenshot:

Thanks for the reply.
I’ve solved the syntax errors but it still won’t work.

I’ve tried the method you’ve suggested but the problem is that the cms item won’t know what “today” is unless it’s a specific date and that won’t work with recurring events.

I still didn’t see the code you posted maybe I’m looking at the wrong page?

Yes you would need to update the date/time field on your events for a ‘today’ filter to work.

No you’re at the right page. But I kept working with the code and managed to fix the errors on my own but it still will not work.

I see that you have code running in your publised site now. Looks like its working from what I see. What exactly is not working?

The filtering of the cms items. All the items are still visible.

Looks like a filtered view in my browser…I probably totally misunderstood the issue :sweat_smile:

That’s weird. It doesn’t look like that on my end. And I think that particular event shouldn’t even be visible yesterday. :thinking: