子比主题美化 – 底部横向网站信息统计模块-zibll教程分享论坛-zibll子比主题-酷梦资源网

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

分享一下子比的底部横向网站统计的模块,有博客播报、文章统计、浏览统计,用起来非常美观而且还非常实用的一个底部美化!!!

图片[1]-子比主题美化 – 底部横向网站信息统计模块-zibll教程分享论坛-zibll子比主题-酷梦资源网

安装教程

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

<script type="text/javascript" >
//文章总数
<?php $count_posts = wp_count_posts(); $published_posts =$count_posts->publish;echo "var tj_rzzs="."'$published_posts'";?>
//本周发布
<?php $post_wpdb = get_posts_count_from_last_168h($post_type ='post');echo "var tj_7d="."'$post_wpdb'";?>
//运行时间
<?php $wdyx_time = floor((time()-strtotime("2022-09-23 13:57:00"))/86400);echo "var tj_wdyx="."'$wdyx_time'";?>
//用户总数
<?php global $wpdb;$users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");echo "var tj_jstext="."'$users'";?>
//总访问量
<?php $post_view = nd_get_all_view();echo "var tj_view="."'$post_view'";?>
</script>

代码部署

路径:/www/wwwroot/tfbkw.com/wp-content/themes/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后台 >> 外观 >> 小工具 >> 首页底部全宽度添加以下代码

<div class="textwidget custom-html-widget"><div id="mizhi-info-wg-mian">
  <div class="mizhi-info-item">
  
  <div class="mizhi-wz-item">
  <div class="mizhi-wz-sty mizhi-wzzs-item">
  <svg class="icon fa-2x" aria-hidden="true">
  <use xlink:href="#icon-wenzhang" rel="external nofollow" ></use>
  </svg>
  <span class="mizhi-i-num"><script type="text/javascript">
  document.write(stat_wzzs);
  </script>篇</span>
  <span class="frame-bg" title="文章数目">文章数目</span>
  </div>
  
  <div class="mizhi-wz-sty mizhi-jrfb-item">
  <svg class="icon fa-2x" aria-hidden="true">
  <use xlink:href="#icon-benzhoudianjihou-copy" rel="external nofollow" ></use>
  </svg>
  <span class="mizhi-i-num"><script type="text/javascript">
  document.write(stat_bzfb);
  </script>篇</span>
  <span class="frame-bg" title="本周发布">本周发布</span>
  </div>
  </div>
  
  <div class="mizhi-yhzs-item">
  <svg class="icon fa-2x" aria-hidden="true">
  <use xlink:href="#icon-yonghu" rel="external nofollow" ></use>
  </svg>
  <span class="mizhi-i-num"><script type="text/javascript">
  document.write(stat_zcyh);
  </script>位</span>
  <span class="frame-bg" title="注册用户">注册用户</span>
  </div>
  
  <div class="mizhi-yxsj-item">
  <svg class="icon fa-2x" aria-hidden="true">
  <use xlink:href="#icon-daojishi" rel="external nofollow" ></use>
  </svg>
  <span class="mizhi-i-num"><script type="text/javascript">
  document.write(stat_yxsj);
  </script>天</span>
  <span class="frame-bg" title="运行时间">运行时间</span>
  </div>
  
  <div class="mizhi-llzs-item">
  <svg class="icon fa-2x" aria-hidden="true">
  <use xlink:href="#icon-yanjing-" rel="external nofollow" ></use>
  </svg>
  <span class="mizhi-i-num "><script type="text/javascript">
  document.write(stat_zfwl);
  </script>次</span>
  <span class="frame-bg" title="浏览次数">浏览次数</span>
  </div>
  
  <div class="mizhi-sjcs-item">
  <div class="mizhi-sjcj-m">
  <span class="mizhi-i-num">——腾飞博客播报 ——</span>
  <div id="mizhi-date-text"></div>
  <div id="mizhi-week-text"></div>
  <div class="mizhi-meo-item">
  <img id="mizhi-meos" src="https://tfbkw.com/tongji/week/week-1.webp" alt="emo">
  </div>
  <div class="mizhi-sjcj-content">
  <span id="mizhi-fatalism"></span>
  </div>
  </div>
  </div>    
  <div class="mizhi-sjcs-item2"><iframe src="https://tfbkw.com/tongji/tkr/" width="290" height="290" frameborder="no"></iframe></div> 
  </div>
  </div>
  <script>
  $(function () {
    var myDate = new Date();
    var year = myDate.getFullYear(); //获取当前年
    var mon = myDate.getMonth() + 1; //获取当前月
    var date = myDate.getDate(); //获取当前日
    var week = myDate.getDay();
    var weeks = [
      "星期日",
      "星期一",
      "星期二",
      "星期三",
      "星期四",
      "星期五",
      "星期六"
    ];
    $("#mizhi-date-text").html(year + "年" + mon + "月" + date + "日"+ weeks[week]);
  
    if (week > 0 && week < 5) {
      $("#mizhi-fatalism").html("再坚持一下还有" + (5 - week) + "天就到周末啦!");
    } else if (week === 5) {
      $("#mizhi-fatalism").html("啊啊啊,明天就是周末啦!");
    } else {
      $("#mizhi-fatalism").html("今天是周末,好好放肆玩一下吧!");
    }
    $("#mizhi-meos").attr(
      "src","https://tfbkw.com/tongji/week/week-" + week + ".webp"
    );
  });
  $("#mizhi-info-wg-mian").parents(".zib-widget").css({
    padding: "0",
    background: "none"
  });
  
  </script></div>
  <link rel="stylesheet" href="https://tfbkw.com/tongji/tj2.css" rel="external nofollow"  type="text/css">

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

<script src="https://at.alicdn.com/t/c/font_4345756_vfsrwfwjfqj.js"></script>

CSS代码

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}

 

  • 海报
  • 打赏
  • 分享
海报图正在生成中...
分享到...
请选择打赏方式
  • 微信
  • 支付宝
请登录后发表评论

    没有回复内容