目前是采用小工具实现
点击外观-》小工具,添加HTML模块
填入下面的代码:
<span id="runtime_span" style="color:#0196e3;"></span> <script type="text/javascript">function show_runtime(){window.setTimeout("show_runtime()",1000);X=new Date("12/18/2021 1:00:00");Y=new Date();T=(Y.getTime()-X.getTime());M=24*60*60*1000;a=T/M;A=Math.floor(a);b=(a-A)*24;B=Math.floor(b);c=(b-B)*60;C=Math.floor((b-B)*60);D=Math.floor((c-C)*60);runtime_span.innerHTML="网站已运行"+A+"天"+B+"小时"+C+"分"+D+"秒"}show_runtime();</script>
其中Date后面的时间是网站建立时间,按照个人需要修改这个时间就行。
然后在个人网站添加WordPress小工具区域,添加该小工具即可。
最终效果: