Do you want to find and display total number of posts published on your WordPress site? Here’s the code.
Get the number of published posts using the $wpdb object, while making sure to exclude the post revisions and auto saved posts.
$agentwp_num variable contains the total number of posts published on your WordPress blog, excluding the auto saved posts and post revisions.
It can be displayed anywhere in the template files with the code below,
echo $agentwp_num.' posts published since we are online!';