How to Display WordPress Total Published Post Count

Here’s a simple little snippet that displays the number of your total published posts on your WordPress site.

If you want to display how many posts you’ve published in your sidebar, you would add this to your sidebar.php file or any other file, such as footer, header, etc.

<?php echo wp_count_posts()->publish; ?>