facebook twitter youtube
in PHP - 05 Jan, 2011, This Tutorial Has Been Viewed 28,096 Times.
by admin - one comment
Display total number of posts and comments in wordpress
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

This tutorial will show you how to display the total number of posts and comments in wordpress.All you have to do is edit your theme say your footer or header or sidebar as you wish :) and then add the following lines.

< ?php
$numposts = $wpdb->get_var("S ELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
if (0 < $numposts) $numposts = number_format($numposts); 
$numcomms = $wpdb->get_var("S ELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);
?>

< ?php echo 'There are '.$numposts . ' posts and ' . $numcomms . ' comments ' . $numcats . ' for this website'; ?>
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Incoming search terms:

Leave a Reply

  • //12 Nov 2012

    Thank you for your sharing.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
Close
Please support the site
By clicking any of these buttons you help our site to get better