子比主题美化-底部横向网站信息统计模块

分享一下子比的底部横向网站统计的模块,有博客播报、文章统计、浏览统计,用起来非常美观而且还非常实用的一个底部美化!!!不知道原创是谁,网上的资源整理测试的。

图片展示

图片[1]-子比主题美化-底部横向网站信息统计模块

教程

子比主题的主题目录下,header.php 底部添加下方核心函数代码

<script type="text/javascript" >
//文章总数
<?php $count_posts = wp_count_posts(); $published_posts =$count_posts->publish;echo "var tj_wzzs="."'$published_posts'";?>
//本周发布
<?php $post_wpdb = get_posts_count_from_last_168h($post_type ='post');echo "var tj_bzfb="."'$post_wpdb'";?>
//运行时间
<?php $wdyx_time = floor((time()-strtotime("2023-11-11 11:11:11"))/86400);echo "var tj_yxsj="."'$wdyx_time'";?>
//用户总数
<?php global $wpdb;$users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");echo "var tj_yhzs="."'$users'";?>
//总访问量
<?php $post_view = nd_get_all_view();echo "var tj_yhzl="."'$post_view'";?>
</script>
	

路径:主题根目录zibll/functions.php
添加如下代码,如有添加过此代码请跳过此步骤。

/* 统计总访问量 */
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 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;
}

WordPress后台 >> 外观>> 小工具 >> 首页底部全宽度自定义HTML添加以下代码

一定要引入图标链接,我这里引入的是阿里的icon的图标,放到自定义底部HTML代码,自己可自行更换,链接如下

<script src="//at.alicdn.com/t/c/font_4054251_lyuxfz4jkfj.js"></script>

最后,Zibll主题设置 >> 全局&功能 >> 自定义代码 >> 自定义CSS样式

.huliku-info-item{display:grid;grid-gap:15px;grid-template-columns: repeat(6,1fr);grid-template-rows:repeat(2,1fr);width:100%;height:280px;margin-bottom:15px;}
.huliku-llzs-item, .huliku-sjcs-item, .huliku-yhzs-item, .huliku-yxsj-item{width:100%;height:100%;border-radius:8px;text-align:center;box-shadow:0 2px 4px 0 rgba(0,0%,0%,5%);background-color:var(--main-bg-color);overflow:hidden;padding:5px;box-sizing:border-box;}
.huliku-i-num{font-size:20px;font-weight:600}
.huliku-yxsj-item{display:flex;align-items:center;justify-content:center;flex-direction:column}
.huliku-yhzs-item{display:flex;align-items:center;justify-content:center;flex-direction:column}
.huliku-llzs-item{display:flex;align-items:center;justify-content:center;flex-direction:column}
.huliku-wz-item{display:grid;grid-gap:20px;grid-template-columns:repeat(2,1fr);grid-column: 3/6;grid-row:1/2;overflow:unset!important;box-shadow:none!important;padding:0!important;}
.huliku-wz-sty{width:100%;height:100%;border-radius:8px;display:flex;align-items:center;justify-content:center;flex-direction:column;background-color:var(--main-bg-color);box-shadow:0 2px 4px 0 rgba(0,0%,0%,5%)}
.huliku-sjcs-item{grid-row: 1/3;grid-column: 1/3;}
.huliku-sjcj-m{position:relative;font-size:20px;font-weight:700;text-align:center;width:100%;height:100%;padding:10px;box-sizing:border-box;}
.huliku-sjcj-content{text-align:center;margin-top:10px}
.huliku-meo-item{width:282px;height:120px;margin:0 auto}
.huliku-meo-item>img{width:100%;height:100%;background-size:cover;background-repeat:no-repeat;background-position:center center;cursor:pointer}
svg.icon.fa-2x {margin-top: 15px;}
@media screen and (max-width:959px){.huliku-info-item{grid-gap:10px;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(4,1fr);height:500px;}
.huliku-sjcs-item{grid-row:3/5;grid-column:1/4}
.huliku-i-num{font-size:20px}
.huliku-sjcj-m{font-size:16px}}
.enlighter-default .enlighter{max-height:400px;overflow-y:auto !important;}.posts-item .item-heading>a {font-weight: bold;color: unset;}@media (max-width:640px) {.meta-right .meta-view{display: unset !important;}}
.huliku-sjcs-item2 {grid-row: 1/3;}
.huliku-sjcs-item2 {width: 100%;height: 100%;border-radius: 8px;text-align: center;box-shadow: 0 2px 4px 0 rgba(0,0%,0%,5%);background-color: var(--main-bg-color);box-sizing: border-box;grid-row: 1/3;grid-column: 6/6;}
@media screen and (max-width:959px){.huliku-wz-item{grid-column: 1/4}.huliku-sjcs-item2 {display:none}}
.huliku-ip-item, .huliku-sjcs-item, .huliku-yhzs-item, .huliku-yxsj-item{width:100%;height:100%;border-radius:8px;text-align:center;box-shadow:0 2px 4px 0 rgba(0,0%,0%,5%);background-color:var(--main-bg-color);overflow:hidden;padding:5px;box-sizing:border-box;}
.huliku-ip-item{display:flex;align-items:center;justify-content:center;flex-direction:column}

以上就是子比主题底部横向美化的全部教程!!

温馨提示:本文最后更新于2024-07-04 14:56:22,某些文章具有时效性,若有错误或已失效,请在下方留言或联系执笔
© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
子比主题美化-底部横向网站信息统计模块-执笔博客
子比主题美化-底部横向网站信息统计模块
此内容为付费阅读,请付费后查看
200积分
付费阅读
已售 14
评论 共6条

请登录后发表评论