今天小编为大家带来利用纯代码和worpress自带的自定义html功能添加倒计时模块,此方法理论上支持所有网站,具体自测吧。
wordpress代码
1、进入WordPress网站后台
2、选择外观-小工具-添加自定义html小工具。
3、填写如下代码:
复制<div class="gn_box">
<h1><center><font color=#E80017>2font><font color=#D1002E>0font><font color=#BA0045>1font><font color=#A3005C>9font><font
color=#8C0073>年font><font color=#75008A>-font><font color=#5E00A1>新font><font
color=#4700B8>年font><font color=#3000CF>倒font><font color=#1900E6>计font><font color=#0200FD>时font>
center>h1>
<center>
<div id="CountMsg" class="HotDate">
<span id="t_d">157 天span>
<span id="t_h">9 时span>
<span id="t_m">7 分span>
<span id="t_s">42 秒span>
div>
center>
<script type="text/javascript"> function getRTime() {
var EndTime = new Date('2020/01/25 00:00:00');
var NowTime = new Date();
var t = EndTime.getTime() - NowTime.getTime();
var d = Math.floor(t / 1000 / 60 / 60 / 24);
var h = Math.floor(t / 1000 / 60 / 60 % 24);
var m = Math.floor(t / 1000 / 60 % 60);
var s = Math.floor(t / 1000 % 60);
document.getElementById("t_d").innerHTML = d + " 天";
document.getElementById("t_h").innerHTML = h + " 时";
document.getElementById("t_m").innerHTML = m + " 分";
document.getElementById("t_s").innerHTML = s + " 秒";
}
setInterval(getRTime, 1000);
script>
div>
4、点击保存,即可前台浏览查看。