How to display number of different post types

If you have started customizing your WordPress powered website, you might actually end up adding numberless features to it. Whether you’re only customizing the frontend or the backend, there are quite a lot of features you can add. One interesting feature you might want to add to your admin panel (if you’re customizing the backend) is displaying the number of different post types in WordPress. For example, a number of published posts, drafts, pages… While this can be helpful for admins, you can also show those numbers to your visitors in a widget or somewhere else on the site.

In this article, we are about to show you small pieces of code which will do the magic. All you need to do is choose which number you want to show and decide where to show it. For example, if you want to show a number of published posts in your footer, you will need to copy & paste the code into footer.php file.

Number of published posts:

echo 'There are ' . wp_count_posts()->publish . ' posts published on our site';

Number of published pages:

echo 'There are ' . wp_count_posts('page')->publish . ' pages published on our site';

Number of drafts:

echo 'There are ' . wp_count_posts()->draft. ' drafts waiting to be published';

Number of custom post types:

In order to show the number of custom post types, you will have to enter the slug of your own custom posts. For example, you might have created a custom post type named “videos”. In that case, use ‘videos’ instead ‘post_type’:


echo 'There are ' . wp_count_posts('post_type')->publish. ' post types published';


echo 'There are ' . wp_count_posts('post_type')->draft. ' post types waiting to be published';


echo 'There are ' . wp_count_posts('post_type')->publish. ' post types thrown in the trash can’;
Start Blog Book


This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *