How to Display Total Number of Posts and Comments on Your Blog
We all love numbers :D right? So, how about showing some statistics on your wordpress blog to attract visitors and let them show your blog in numbers.
We all love numbers :D right? So, how about showing some statistics on your wordpress blog to attract visitors and let them show your blog in numbers.
<?php
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
if (0 < $numposts) $numposts = number_format($numposts);
echo 'We have published '.$numposts.' since our launch.';
?>
<?php
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);
echo 'Our readers have made '.$numcomms.' comments so far.';
?>
Thanks to Jeff Starr for sharing this code.
Thanks for sharing this info.