為 WordPress 日曆的星期六日加上顏色 (2)


如果想將星期六和日以不同顏色顯示只需要加多一個樣式進入 CSS

  1. 先打開 wp-content/themes/{模版}/style.css 加入
1
2
3
4
5
6
#wp-calendar .holiday_sun { 
color: red;
}
#wp-calendar .holiday_sat {
color: green;
}
  1. 之後再根據前面的改法將
1
2
3
4
5
6
7
if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) { 
$tmp_day = "<span class=\"holiday\">$day</span>";
}elseif (0 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins)) {
$tmp_day = "<span class=\"holiday\">$day</span>";
}else{
$tmp_day = $day;
}

改為

1
2
3
4
5
6
7
if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) { 
$tmp_day = "<span class=\"holiday_sat\">$day</span>";
}elseif (0 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins)) {
$tmp_day = "<span class=\"holiday_sun\">$day</span>";
}else{
$tmp_day = $day;
}