阅读本文大约需要:1 分钟

1、在Function.php中加入:

function colorlapse() {
	date_default_timezone_set('Asia/Shanghai');
	$hour=date("H"); 
	$colorlapse = "#555";
	if($hour>=0 && $hour<=4): $colorlapse="#6a6f6f";
	elseif($hour>4 && $hour<=5): $colorlapse="#8a8f8f";
	elseif($hour>5 && $hour<=6): $colorlapse="#9a9f9f";
	elseif($hour>6 && $hour<=7): $colorlapse="#aaafaf";
	elseif($hour>7 && $hour<=8): $colorlapse="#babfbf";
	elseif($hour>8 && $hour<=9): $colorlapse="#cacfcf";
	elseif($hour>9 && $hour<=12): $colorlapse="#dadfdf";
	elseif($hour>12 && $hour<=13): $colorlapse="#eaefef";
	elseif($hour>13 && $hour<=14): $colorlapse="#fdfefe";
	elseif($hour>14 && $hour<=15): $colorlapse="#dadfdf";
	elseif($hour>15 && $hour<=16): $colorlapse="#cacfcf";
	elseif($hour>16 && $hour<=17): $colorlapse="#babfbf";
	elseif($hour>17 && $hour<=18): $colorlapse="#babfbf";
	elseif($hour>18 && $hour<=19): $colorlapse="#aaafaf";
	elseif($hour>19 && $hour<=20): $colorlapse="#9a9f9f";
	elseif($hour>20 && $hour<=24): $colorlapse="#8a8f8f";
	else: $colorlapse="#555";
	endif;
	return $colorlapse;
}

2、在header.php中找到标签,更改为:

部分内容回复可见

转载请注明来源:WordPress教程]WordPress根据时间自动切换主题配图和颜色