In a recent project, I was looking to find out how many posts were in a Feedback custom post type, to display on a Dashboard widget similar to the “Right Now” Dashboard Widget that comes with WordPress.
I noticed that the only way to get a count of posts within a certain post type was using:
wp_count_posts( 'my_post_type' );
wp_count_posts() returns an object, which gives detailed information of each post status and how many posts were within that status. If you are using default post statuses, you can probably get away with this:
Continue reading How to Get the total number of Posts in WordPress