Display the Total Number of WordPress Posts, Comments, and Categories

Would you like to display the total number of posts, comments, and categories for your WordPress-powered website? Here is the code that can make it happen 1! Update: The count posts part of this method should only be used for WordPress versions less than 2.5. For WordPress versions 2.5 and better, there is a built-in function for displaying the total number of posts. See The WordPress Codex for more information. <?php $numposts = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = ‘publish'”); if (0 < $numposts) $numposts = number_format($numposts); $numcomms = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = ‘1’”); if (0 […] Read more »