展示

本周发布
投放路径:/www/wwwroot/huliku.com/wp-content/themes/zibll/functions.php
将下方代码粘贴至functions.php
文件内即可。否则“本周发布”将不显示或出现错乱。如已添加过请忽略。
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;}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; }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; }
总访问量
使用方法同上,如未添加此代码将不显示统计效果或出现错乱,如已添加过请忽略此步
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;}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; }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; }
其他代码
部署教程
代码和需要用到的图片已经打包在下方,需要的可在下方下载。
- CSS代码和JS代码上传到网站根目录解压即可(调用默认根目录,亦可自行选择更换上传目录)。
- 部署路径:
/www/wwwroot/huliku.com/wp-content/themes/zibll/footer.php
先备份原文件,将下载的footer.php
代码直接覆盖即可。
- 部署路径:
- 把所有图片路径和链接修改成你自己的即可大功告成了!
暂无评论内容