请选择 进入手机版 | 继续访问电脑版

环境生态社区

 找回密码
 注册

QQ登录

只需一步,快速开始

微信登录

微信扫一扫,快速登录

查看: 6165|回复: 0

[BLOG] WordPress的统计函数

[复制链接]
发表于 2017-9-25 22:04:03 | 显示全部楼层 |阅读模式
日志总数:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?> 篇
总访问量:<?php get_totalviews(true, true, true); ?> 次 //配合wp-postviews插件才可以用。
评论总数:<?php $total_comments = get_comment_count(); echo $total_comments['approved'];?> 条
注册会员:<?php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?> 个
链接总数:<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?> 个
最新更新:<?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; ?>
页面总数:<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?> 个
草稿:<?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?> 篇
栏目分类总数:<?php echo $count_categories = wp_count_terms('category'); ?> 个
标签总数:<?php echo $count_tags = wp_count_terms('post_tag'); ?> 个
您需要登录后才可以回帖 登录 | 注册 微信登录

本版积分规则

快速回复 返回顶部 返回列表