Last updated on January 23rd, 2022 at 09:38 am
Display total post count in WordPress
If you want to display total number of posts you have published on your blog or website this simple code will help you.
NOTE:-If you are using this script outside wordpress, Make sure you add it after calling the WordPress header file wp-blog-header.php.
<?php $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'"); if (0 < $numposts) $numposts = number_format($numposts); ?><b><?php echo '<p><font color=black><h1>'.$numposts.' Tutorials / Scripts Published'; ?>
If you would like to display total number of comments and posts then check this How to get total posts | comments count in WordPress