I’m using WordPress (which may or may not be relevant) but I’m trying to add a class to the body based on the time of the year.
I have three ‘themes’ on the site; spring, summer and autumn. If the period is Feb-May, for example, the class on the body would be ‘spring’. If the period is Jun-September the class on the body would be ‘summer’, and so forth.
Any ideas how I would achieve this?
Currently the body already has relevant classes based on which page you are on (WordPress default) which looks like this
<body <?php body_class(); ?>>
But you can add your own class by doing
<body <?php body_class('a-new-class'); ?>>
Any help would be appreciated â I’m guessing a simple PHP if statement to do with dates?
Cheers,
R
PHP:
HTML: