Website Scripts And Cloud Tutorials

Display total post count in WordPress

Byadmin

May 10, 2015
migrate GD star to YASR plugin in WordPress

Last updated on January 23rd, 2022 at 09:38 am

Click to rate this tutorial!
[Total: 0 Average: 0]

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'; ?>

DEMO

If you would like to display total number of comments and posts then check this How to get total posts | comments count in WordPress

Click to rate this tutorial!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published.