首页 技术教程wordpress教程WordPress获取文章统计数量及评论数量

WordPress获取文章统计数量及评论数量

沐辰客栈 2021-05-16 12:55:40 1 111
  1. 日志总数:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?>
  2. 评论总数:<?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?>
  3. 分类总数:<?php echo $count_categories = wp_count_terms('category'); ?>
  4. 标签总数:<?php echo $count_tags = wp_count_terms('post_tag'); ?>
  5. 友情链接:<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?>
  6. 网站运行:<?php echo floor((time()-strtotime("2011-7-27"))/86400); ?>
  7. 最后更新:<?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; ?>
分享本文至:
发表评论
评论列表:
2021-05-15 17:32
没有用过wp