教程开始
1.下载的文件除了footer.php上传到网站根目录解压即可(调用默认根目录,亦可自行选择更换上传目录)
2.footer.php去themes/zibll/footer.php
中更改替换(切记备份 原文件)
3.把所有图片路径和链接修改成你自己的即可大功告成了!
正式开始:
添加以下代码到/www/wwwroot/域名/wp-content/themes/zibll/functions.php
/* * @Project : 统计本周文章数量 */ function get_posts_count_from_last_168h($post_type ='post') { global $wpdb; $numposts = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) ". "FROM {$wpdb->posts} ". "WHERE ". "post_status='publish' ". "AND post_type= %s ". "AND post_date> %s", $post_type, date('Y-m-d H:i:s', strtotime('-168 hours')) ) ); return $numposts; }
统计代码
和上面一样没有添加过此类美化的也是添加到/www/wwwroot/域名/wp-content/themes/zibll/functions.php
/* * @Project : 统计总访问量 */ function nd_get_all_view(){ global $wpdb; $count=0; $views= $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE meta_key='views'"); foreach($views as $key=>$value){ $meta_value=$value->meta_value; if($meta_value!=' '){ $count+=(int)$meta_value; } }return $count; }
数据库加载统计
样式1:
在 zibll 主题目录下 themes/zibll/footer.php
文件中的顶部添加下面的代码
<!---给网站数据库查询&页面加载耗时功能---> <center> <p> 本次数据库查询:<?php echo get_num_queries(); ?>次 页面加载耗时<?php timer_stop(3); ?> 秒</p> </center> <!---网站数据库查询&页面加载耗时--->
样式2:
在 themes/zibll/functions.php
文件中加入以下代码
/*显示查询次数、查询时间及消耗内存*/ function performance( $visible = true ) { $stat = sprintf( '%d 次查询 | 用时 %.3f 秒 | 消耗 %.2fMB 内存', get_num_queries(), timer_stop( 0, 3 ), memory_get_peak_usage() / 1024 / 1024 ); echo $visible ? $stat : "<!-- {$stat} -->" ; }
在 zibll 主题目录下 themes/zibll/footer.php 文件中的顶部添加下面的代码
本页面加载共:<?php if(function_exists('performance')) performance(true) ;?>
版权声明:原创作品,未经允许不得转载,否则将追究法律责任。
本站资源有的自互联网收集整理,如果侵犯了您的合法权益,请联系本站我们会及时删除。
本站资源仅供研究、学习交流之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。
本文链接:壹码资源网https://www.yimazy.com/171238.html
许可协议:《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
本站资源有的自互联网收集整理,如果侵犯了您的合法权益,请联系本站我们会及时删除。
本站资源仅供研究、学习交流之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。
本文链接:壹码资源网https://www.yimazy.com/171238.html
许可协议:《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
评论(0)