How to Display Total Posts Published Count in WordPress using PHP ?

Today, I wanted to display on my homepage, a total post published count, so after searching for this, I found a very interesting piece of code that does this job, check out the code below…

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

Below is a cut off from my homepage, where I am displaying a total number of posts published using this very code.

Hope this helps you too