今天是: 2020年10月25日 星期日

您现在的位置是:
首页 » 技术分享 » 如何获取WordPress的文章总数评论总数及用户总数

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

1、文章总数(已发布):<?php $count_posts = wp_count_posts(); echo $publish_posts = $count_posts->publish; ?>篇

 

2、日志总数:<?php $count_posts = wp_count_posts(); echo $published_posts =$count_posts->publish;?>篇

3、草稿总数:<?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?>

4、页面总数:<?php $count_pages = wp_count_posts(‘page’); echo $page_posts = $count_pages->publish; ?>

5、用户总数:<?php $users = $wpdb->get_var(“SELECT COUNT(ID) FROM $wpdb->users”); echo $users; ?>

6、成立时间:<?php echo floor((time()-strtotime(“2009-8-23”))/86400); ?> //其中的年月日改成你自己的网站成立时间

7、分类总数:<?php echo $count_categories = wp_count_terms(‘category’); ?>个

8、标签总数:<?php echo $count_tags = wp_count_terms(‘post_tag’); ?>个

9、友情链接:<?php $link = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = ‘Y'”); echo $link; ?>个

10、网站运行:<?php echo floor((time()-strtotime(“2011-7-27”))/86400); ?>天

11、最后更新:<?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; ?>

点赞