获取WordPress的文章总数评论总数及用户总数

有时做一些统计数据,需要调取WordPress的文章总数、评论总数以及用户总数,这些该如何获取?

共有2个回答 按发表时间排序
  • 1
    最佳答案
    知更鸟 - 2011-08-21
    日志总数:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?>篇
    评论总数:<?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?>条
    分类总数:<?php echo $count_categories = wp_count_terms('category'); ?>个
    标签总数:<?php echo $count_tags = wp_count_terms('post_tag'); ?>个
    友情链接:<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?>个
    网站运行:<?php echo floor((time()-strtotime("2011-7-27"))/86400); ?>天
    最后更新:<?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; ?>
    

    用户总数木有,楼下继续

  • 0
    Packy_ - 2012-04-30

    那如果是“今日更新文章”的统计呢?

做好事要留名,请先登录再回答,如果还没有帐户请先注册