今天在网上突然发现有这么一个小工具纯代码即可实现页面查询和访问次数,今天西瓜君就给大家分享出来,只要访客的cookies没有清理,这个功能会一直有效。
效果图
使用方法
进入WordPress后台以后,找到外观——小工具。
将文中西瓜君提供的代码粘贴到,增强文本当中,最后保存即可。
代码
<div style="text-align:center;"><script type="text/javascript""> if(localStorage.pagecount){localStorage.pagecount=Number(localStorage.pagecount)+1}else{localStorage.pagecount=1}document.write("你第"+localStorage.pagecount+"次来独家博客"); </script></div>
<div class="table-r">
<table width="100%">
<tbody>
<tr>
<td style="text-align:center;" width="50%">页面加载<?php timer_stop(1); ?>秒</td>
<td style="text-align:center;" width="50%">页面查询<?php echo get_num_queries(); ?>次</td>
</tr>
</tbody>
</table>
</div>