Querying WordPress Posts by Type and Status
The wp_count_posts() function returns a count object for any post type, making it essential for dashboards, theme displays, admin queries, and performance monitoring. Understanding how to use it correctly—and when to optimize—matters for WordPress development. Basic Usage <?php $count_posts = wp_count_posts(); $published = $count_posts->publish; echo $published . ” published posts”; ?> By default, wp_count_posts() counts…
