B2主题底部网站统计美化

效果图

B2主题底部网站统计美化

插入代码到子主题style.css里

 


/*底部统计美化开始*/


.b2-content {
    display: block;
    flex-flow: row;
}
.siteCount {
    position: relative;
    padding: 60px 0;
    margin-top: 30px;
    background: url('https://lmtd.cn/pic/tjbj.jpg') center center / cover no-repeat fixed;
}
.siteCount .cover {
    height: 100%;
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    position: absolute;
    top: 0;
    left: 0;
}
.siteCount .wrapper {
    position: relative;

}
.siteCount ul {
    display: flex;
}
.siteCount ul li {
    width: 20%;
    color: #fff;
    text-align: center;
}
.siteCount ul li b {
    display: block;
    font-weight: normal;
    font-size: 14px;
}
.siteCount ul li span {
    font-size: 48px;
    font-family: Arial;
}
.siteCount .join-vip {
    text-align: center;
    color: #fff;
    margin-top: 30px;
}
.siteCount .join-vip a {
    display: inline-block;
    border: 0;
    transition: all .3s;
    padding: 10px 30px;
    font-size: 15px;
    letter-spacing: .5px;
    background: #ef950c;
    color: #fff;
}
.siteCount .join-vip a:hover {
    transform: translateY(-3px);
}
.siteCount .join-vip p {
    margin-top: 15px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.80);
    letter-spacing: .5px;
    font-family: Arial;
}
/*底部统计美化结束*/

插入代码到子主题style.css里


/*底部统计开始*/
/*
 * WordPress获取指定用户评论数量
 */
function get_user_comment_count($user_id){
    global $wpdb;
    $count = $wpdb->get_var(' SELECT COUNT(comment_ID) FROM ' . $wpdb->comments. ' WHERE user_id="' . $user_id . '"');
    return $count ? $count : 0;
}

/*
 * WordPress获取指定作者文章总浏览量
 */
if(!function_exists('cx_posts_views')) {
    function cx_posts_views($author_id = 1 ,$display = true) {
        global $wpdb;
        $sql = "SELECT SUM(meta_value+0) FROM $wpdb->posts left join $wpdb->postmeta on ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE meta_key = 'views' AND post_author =$author_id";
        $comment_views = intval($wpdb->get_var($sql));
        if($display) {
            echo number_format_i18n($comment_views);
        } else {
            return $comment_views;
        }
    }
}
/*
 * WordPress整站文章访问计数
 */

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;
}
/*
 * WordPress获取一周发布文章数量
 */
function nd_get_week_post_count(){
    $date_query = array(
        array(
        'after'=>'1 week ago'
        )
    );
    $args = array(
        'post_type' => 'post',
        'post_status'=>'publish',
        'date_query' => $date_query,
        'no_found_rows' => true,
        'suppress_filters' => true,
        'fields'=>'ids',
        'posts_per_page'=>-1
    );
    $query = new WP_Query( $args );
    return $query->post_count;
}
/*
 * WordPress获取今日发布文章数量
 */
function nd_get_24h_post_count(){
    $today = getdate();
    $query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"]);
    $postsNumber = $query->found_posts;
    return $postsNumber;
}
/*底部统计结束*/


7B2美化

7b2主题美化之VIP会员页面

2024-5-18 19:40:44

7B2美化

限制重复评论和间隔时间代码

2024-5-18 19:51:27

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧