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;
}
/*底部统计美化结束*/
插入子主题function.php里面
/*底部统计开始*/
/*
* WordPress获取指定用户评论数量
* 暖岛整理 www.nuandao.cn
*/
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获取指定作者文章总浏览量
* 暖岛整理 www.nuandao.cn
*/
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整站文章访问计数
* 暖岛整理 www.nuandao.cn
*/
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获取一周发布文章数量
* 暖岛整理 www.nuandao.cn
*/
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获取今日发布文章数量
* 暖岛整理 www.nuandao.cn
*/
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;
}
/*底部统计结束*/
用到的一张图片,自行上传
附件里面的文件覆盖子主题
若下载地址失效请在下方留言或联系客服
声明:本站部分文章来源于网络,如有危害到您的合法权益请联系客服
5666666
666
坎坎坷坷
6666666
感谢分享
感谢分享
谢谢
谢谢
谢谢
好好好
asdadadasdad
冲冲冲
收到滴答滴答滴答滴答
漂亮
漂亮漂亮!!!
收到滴答滴答滴答滴答
收到滴答滴答滴答滴答
收到滴答滴答滴答滴答
学习
要么庸俗,要么孤独
多谢分享
单独的
单独的