说明:此教程主要以安装b2的子主题为例
1、从b2父主题根目录下复制footer.php文件粘贴到子主题下,在

块标签下,粘贴文件中的tongji.php内容,然后保存此文件;
2、在子主题下新建根目录Assets,然后在新建js目录,上传压缩包中的两个js文件
3、在子主题根目录下的style.css加入压缩包中的CSS,然后保存此文件
4、在子主题根目录下,引入压缩包中的js文件,代码如下

  1. wp_enqueue_script( b2-jquery’,B2_CHILD_URI.‘/Assets/js/jquery.min.js’, array(), null , false );
  2. wp_enqueue_script( b2-footer’,B2_CHILD_URI.‘/Assets/js/footer_count.js’, array(), B2_VERSION , true);

接着在下方引入文件内容:

// 每周更新的文章数量
function 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 );
echo $query->post_count;
}
// 每日更新的文章数量
function WeeklyUpdate() {
$today = getdate();
$query = new WP_Query( ‘year=’ . $today[“year”] . ‘&monthnum=’ . $today[“mon”] . ‘&day=’ . $today[“mday”]);
$postsNumber = $query->found_posts;
echo $postsNumber;
}

b2主题文章内容美化H标签

代码部署

将下列代码加入到styles.css之中,强制刷新缓存即可

/*文章内容美化H标签 start*/
.entry–content > h2::before{content: ”;margin–right:0;}
.single–article .entry–content > h2{
font–weight: bold;
background–color: #f6f6f6;
margin: 20px 0;
padding: 5px 12px;
border–left: 5px solid #0061a8;
font–size: 21px;
left: –25px;
position: inherit;
}
.single–article .entry–content > h3{
font–weight: bold;
background–color: #f6f6f6;
margin: 20px 0;
padding: 5px 12px;
border–left: 5px solid #037ad1;
font–size: 18px;
left: –25px;
position: inherit;
}
.single–article .entry–content > h4{
font–weight: bold;
background–color: #f6f6f6;
margin: 20px 0;
padding: 5px 12px;
border–left: 5px solid #3a89c3;
font–size: 15px;
left: –25px;
position: inherit;
}
.single–article .entry–content > h5{
font–weight: bold;
background–color: #f6f6f6;
margin: 20px 0;
padding: 5px 12px;
border–left: 5px solid #FFC0CB;
font–size: 12px;
left: –25px;
position: inherit;
}
/*文章内容美化H标签 end*/