wordpress统计函数大全

1、日志总数:

[cce_php]<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?>[/cce_php]

2、草稿数目:

[cce_php]<?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?>[/cce_php]

3、评论总数:

[cce_php]<?php echo $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments”);?>[/cce_php]

4、成立时间:

[cce_php]<?php echo floor((time()-strtotime(“2008-8-18″))/86400); ?>[/cce_php]

5、标签总数:

[cce_php]<?php echo $count_tags = wp_count_terms(‘post_tag’); ?>[/cce_php]

6、页面总数:

[cce_php]<?php $count_pages = wp_count_posts(‘page’); echo $page_posts = $count_pages->publish; ?>[/cce_php]

7、分类总数:

[cce_php]<?php echo $count_categories = wp_count_terms(‘category’); ?>[/cce_php]

8、链接总数:

[cce_php]<?php $link = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = ‘Y’”); echo $link; ?>[/cce_php]

9、用户总数:

[cce_php]<?php $users = $wpdb->get_var(“SELECT COUNT(ID) FROM $wpdb->users”); echo $users; ?>[/cce_php]

10、最后更新:

[cce_php]<?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; ?>[/cce_php]

相关新闻