I NEED YOUR HELP PLEASE!
I have a client that wants to change the background color of all h1 h2 h3s and certain sections’ background color according to the season that they are in, but for the life of me I just can’t and PHP is my weakest point. Is there anyone here that would be able to give me advice on this and how I would implement it on a WordPress website? I did find the following code snippet online but i would need to modify this so that it selects a specific style sheet, and then how do i setup the style sheet to be php and get it start styling…
Much love to all!
function current_season() {
// Locate the icons
$icons = array(
"spring" => "images/spring.png",
"summer" => "images/summer.png",
"autumn" => "images/autumn.png",
"winter" => "images/winter.png"
);
// What is today's date - number
$day = date("z");
// Days of spring
$spring_starts = date("z", strtotime("March 21"));
$spring_ends = date("z", strtotime("June 20"));
// Days of summer
$summer_starts = date("z", strtotime("June 21"));
$summer_ends = date("z", strtotime("September 22"));
// Days of autumn
$autumn_starts = date("z", strtotime("September 23"));
$autumn_ends = date("z", strtotime("December 20"));
// If $day is between the days of spring, summer, autumn, and winter
if( $day >= $spring_starts && $day <= $spring_ends ) :
$season = "spring";
elseif( $day >= $summer_starts && $day <= $summer_ends ) :
$season = "summer";
elseif( $day >= $autumn_starts && $day <= $autumn_ends ) :
$season = "autumn";
else :
$season = "winter";
endif;
$image_path = $icons[$season];
echo $image_path;
}
?>```
2
Answers
hey all so after reading/studying and taking your answers into consideration, I managed to develop a solution so here it is:
I would use same css file for all seasons, only differentiating them by the class you would add to the
body
tag according to the season.PHP
css
etc.