Header image automatically changes depending on season

Question

For days trying to figure out what is wrong with script. As a theme using ‘primer’. Point is to make header image change by itself for each season. At page header appears fall and thats it, even when im testing different months for different seasons, nothing happens. Maybe somebody can help me solve this issue.

funcion

    add_filter('masthead','site-header');
function seasonal_site_header ($classes = '') {
   $hemisphere = 'northern';
   $m = date('m');
    
   $northern=array(
     'summer' => array(6, 7, 8),
     'fall' => array(9, 10, 11),
     'winter' => array(12, 1, 2),
     'spring' => array(3, 4, 5)
   );

   foreach($$hemisphere as $key=>$val) {
     if(in_array($m, $val)) {
       $classes[] = $key;
       return $classes;
     }
   }
   $classes[] = '';
   return $classes;
}

css

#masthead, .site-header, .winter
{
  background-image: url('/wp-content/uploads/2020/09/winter.jpg');

}
#masthead, .site-header, .spring
{
  background-image: url('/wp-content/uploads/2020/09/spring.jpeg');

}
#masthead, .site-header, .summer #site-header-wrapper
{
  background-image: url('/wp-content/uploads/2020/09/summer.jpeg');

}
#masthead, .site-header, .fall
{
  background-image: url('/wp-content/uploads/2020/09/autumn.jpg');

}
0
sfera 4 months 0 Answers 9 views 0

Leave an answer