反正原来的那个统计代码太麻烦了。。。statpresscn。在后台显示的还好。今天然后逛Dianso博客的时候看见这样的代码,就copy过来了。算个备份,虽然以后找的到,但是找起来麻烦的。。。。

1. 用户总数

<?php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?> 位</li>

2. 日志总数

<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?> 篇</li>

3. 评论总数

<span title="访客/管理员:<?php $comment_guest = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type != 'trackback' AND comment_type != 'pingback' AND user_id = 0"); echo $comment_guest; ?>/<?php $comment_author = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type != 'trackback' AND comment_type != 'pingback' AND user_id > 0"); echo $comment_author; ?>">评论总数:<?php
$comment = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type != 'trackback' AND comment_type != 'pingback'");
echo $comment;?></span> 篇</li>

4. 标签总数

<?php echo $count_tags = wp_count_terms('post_tag'); ?> 个</li>

5. 分类总数

<?php echo $count_categories = wp_count_terms('category'); ?> 个</li>

6. 页面总数

<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?> 个</li>

7. 链接总数

<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?> 个</li>

8.成立时间

<span title="已经在线 &lt;?php echo floor((time()-strtotime("> 天"&gt;成立时间:2009.7.5</span>

9. 最后更新

<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");
$last = date('Y-n-j g:ia', strtotime($last[0]->MAX_m));
echo $last; ?>

10. 草稿数目

<?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?>

via:http://014.cc/910