WordPress统计代码

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.成立时间

<?php echo floor((time()-strtotime("2008-8-18"))/86400); ?>

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', strtotime($last[0]->MAX_m));echo $last; ?>

10. 草稿数目

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

via:http://sunsunsun.org/wordpress/wp-tutorials/also-get-rid-of-a-plugin-wordpress-statistics-code.html

{ 发表评论? }

  1. havefu

    路过,留名~

  2. 瘦小腿

    wp的每篇文章的浏览次数是用什么函数统计出来的,不想用插件,也没有留言功能

    • TC

      不错的方法!
      空间好漂亮

  3. how to bbq

    014.cc的博主前辈,问个新手问题:如果出售广告位,一般自己网站要有什么的条件才能达到?

  4. ylsnuha

    哎呀 这个不错 。。。先留着了 哈哈

  5. 减掉大象腿

    很不错的博客,我也要弄个像这样的。很漂亮。

  6. 阿溪

    博客很漂亮!!!
    来留个名!! :lol:

  7. 扒站

    很专业的博客,受益匪浅.

发表评论

电子邮件地址不会被公开。

 smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

无觅相关文章插件,快速提升流量