Visibility condition based on today's date

still working on my mountain guides site… i’d like to automatically show activities based on today’s date. For example, between december and april, i want to show winter activities repeater on my homepage. And between may and october, i want to show summer activities.
So, i’ve built to similar repeaters on the homepage, one for summer activities and one for winter activities.
Now i’d like to display only one, depending on which day we are when visiting the site.

And i don’t understand how to do this… can someone help me with that ? @StrangeTech @Araminta @Lijn-B @yankiara any idea ?

@pomilo There are several different ways to do this - firstly, just to confirm, are you basing it on the day of the week or the day of the month?

@StrangeTech i don’t care about the day, i care about the date (and not of the year, i need it to work each year). For example if we are december 1st i want winter activities to display. If we are june 12th, i want to show summer activities
Is it clearer ?

OK, so this is fairly straightforward.

Add the following code either in a snippet or in your functions:
Screenshot 2024-04-08 at 14.42.23

Just add the following visibility conditions to your repeaters:

June to December:
Screenshot 2024-04-08 at 14.31.31

December to June:
Screenshot 2024-04-08 at 14.41.57

1 Like

thanks Dan for the solution! i haven’t tested yet coz i had some bad news from client (but it seems like the site will eventually be published next month! Yay!)

when you say add it in your functions, you mean directly in the function.php file ?

1 Like


Please see this tip:

1 Like

actually it was much simple than that, no need for custom php code

visibility conditions for winter (mid november to mid may)

and visibility conditions for summer (mid may to mid november)

I am not sure how this part will work the way you want, as the date of the mid-May will be the same year, not next year, which means it falls BEFORE November… I was under the impression you wanted to catch from the current November, to the next May.

yeah, but current may must be here too, and and if the code displays “between current november and next may” what happens for “current january” ? see what i mean ? coz next year we will be the next current year (no, my brain is not twisted at all!)

I see now what you are doing - the current date is always going to be in the current year and you are using an OR condition to cover the rest of the year - makes perfect sense. :+1:


I think you can achieve this by incorporating some simple date-based logic into your website’s code. Here’s a basic approach:

  1. Determine the current month:
  • You can do this using JavaScript’s Date object or any server-side scripting language like PHP.
  1. Based on the current month, decide which activities to display:
  • If the current month falls between December and April, display winter activities.
  • If the current month falls between May and October, display summer activities.
  • You can use conditional statements (if-else or switch-case) to handle this logic.
  1. Adjust the visibility of the activity repeaters accordingly:
  • Use CSS or JavaScript to hide/show the appropriate repeater based on the current month.