配置日历和天气
定义的方式是 自定义HTML,如下图
具体的代码:
<iframe width="270" scrolling="no" height="90" style="margin-left: 0px" frameborder="0" allowtransparency="true" src="https://i.tianqi.com?c=code&id=7&icon=1&site=13"></iframe>
效果:
配置网站统计数据
配置方式为PHP代码,如下图:
建站天数: <?php
function diffDate($date1,$date2){
$datetime1 = new DateTime($date1);
$datetime2 = new DateTime($date2);
$interval = $datetime1->diff($datetime2);
$time['y'] = $interval->format('%y');
$time['m'] = $interval->format('%m');
$time['d'] = $interval->format('%d');
$time['h'] = $interval->format('%H');
$time['i'] = $interval->format('%i');
$time['s'] = $interval->format('%s');
$time['a'] = $interval->format('%a'); // 两个时间相差总天数
return $time['y'].'年 '.$time['m'].'月 '.$time['d'].'天';
}
echo diffDate(date('Y-m-d H:i:s', time()), '2019-08-16 00:00:00');
?>
文章总数: <?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?> 篇
最后更新: <?php
function get_last_post_date(){
global $wpdb;
$last_post_date='';
$last=$wpdb->get_var("select date_format(post_date, '%Y-%m-%d') from $wpdb->posts where post_type='post' and post_status='publish' order by post_date desc limit 1");
return $last;
}
echo get_last_post_date();
?>
总浏览量: <?php
function get_all_post_view(){
global $wpdb;
$count=0;
$views= $wpdb->get_results("SELECT t1.* FROM $wpdb->postmeta t1,$wpdb->posts t2 WHERE t1.meta_key='views' and t1.post_id=t2.id and t2.post_type='post'");
foreach($views as $key=>$value){
$meta_value=$value->meta_value;
if($meta_value!=' '){
$count+=(int)$meta_value;
}
}
return $count;
}
echo number_format(get_all_post_view(),0,".",",");
?> 人次
总评论数: <?php $total_comments = get_comment_count(); echo $total_comments['approved'];?> 条
效果: