王桂明今天修改loper主题,想给博客一个站点统计,第一个方案要是让小工具,本想创建wordpress小工具支持php代码,多次测试最后更新文章总是出错,装插件也是这样,说明主题侧边栏函数有冲突,不知是什么情况,于是只能写了一个php文件,在侧边栏里调实现。
先建一个php文件,里面代码如图:
代码如下:
<!--站点统计--> <div> </div> <div class="widgit-area"> <h3>站点统计 · Site statistics</h3> <ul class="ulstyle"> <li>站点成立:2015年3月30日 距今<?php echo floor((time()-strtotime("2015-3-30"))/86400); ?>天</li> <li>文章数量:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?></li> <li>评论数量:<?php $total_comments = get_comment_count(); echo $total_comments['approved'];?></li> <li>最后更新:<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')"); $last = date('Y年n月j日', strtotime($last[0]->MAX_m));echo $last; ?></li> <li>总访问量:<?php get_totalviews(true, true, true); ?> 次</li> </ul> </div> |
» 本文链接:
http://www.0523jz.com/236.html
» 订阅本站:
http://www.0523jz.com/feed
» 转载请注明来源:王桂明's Blog
» 《loper主题站点统计的添加》