WordPress站点统计功能代码(文章数/建站天数等)

人生坎坎坷坷,跌跌撞撞那是在所难免。但是,不论跌了多少次,你都要坚强地再次站起来。再试一次,成功一定属于你!

最近有同学询问倡萌,如何实现网站的基本信息统计功能,包括网站文章数、评论数、建站天数等等。在万戈博客找到了对应的WordPress站点统计功能代码,需要的朋友就自己添加吧。下面只给出对应的统计函数,最终的样式就要靠大家自己折腾了。

1、日志总数:

1
<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?>

<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?>

2、草稿数目:

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

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

3、评论总数:

1
<?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?>

<?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?>

4、建站天数:

1
<?php echo floor((time()-strtotime("2012-11-22"))/86400); ?>

<?php echo floor((time()-strtotime("2012-11-22"))/86400); ?>

记得修改 2012-11-22 为你的建站日期

5、标签总数:

1
<?php echo $count_tags = wp_count_terms('post_tag'); ?>

<?php echo $count_tags = wp_count_terms('post_tag'); ?>

6、页面总数:

1
<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?>

<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?>

7、分类总数:

1
<?php echo $count_categories = wp_count_terms('category'); ?>

<?php echo $count_categories = wp_count_terms('category'); ?>

8、链接总数:

1
<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?>

<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?>

9、用户总数:

1
<?php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?>

<?php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?>

10、最后更新:

1
<?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 $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; ?>

根据自己的需要使用吧。

到此这篇关于WordPress站点统计功能代码(文章数/建站天数等)就介绍到这了。健康没有捷径,来自点滴习惯的养成;养生只能自学,随时保持学习的状态。更多相关WordPress站点统计功能代码(文章数/建站天数等)内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

您可能有感兴趣的文章
WordPress站点Gravatar头像前后台不显示的如何解决办法

WordPress做公司官网好吗?会不会显得档次很低?

WordPress主题需要支持https吗?WordPress站点如何如何实现https?

WordPress站点的页面/标签/分类URL地址如何添加.html?

WordPress站点更换了域名后数据库应该如何操作替换新旧域名?