WordPress’ ALL post count info on its dashboard does not match phpMyAdmin’s ALL post count!

While phpmyadmin’s wp_posts table reports something like this

Showing rows 0 - 29 (10,223 total, Query took 0.0022 sec)
SQL query:
SELECT * FROM  `wp_posts` LIMIT 0 , 30

WordPress’s dashboard reports

Read More
All (10,222) | Published (10,222)
Search Posts:  10,222 items « ‹  of 512 › » 

As you can see, there is a disconnect here… 10,222 != 10,223

Does anyone know why WordPress reports 1 less then the actual all post count?

Related posts

Leave a Reply

1 comment

  1. It all comes down to this.
    http://core.trac.wordpress.org/ticket/11889

    Behind the scenes, WordPress does generate a place-holder post for your next one! And for that special post, it sets the post_status to a special one, ‘auto-draft’. Basically, the culprit is the post generated by WordPress without your knowledge.

    Once you know this fact, it is easy to understand why there is a disconnect. WordPress admin screen’s ALL count info is based on ALL posts except this special one. WordPress’s SQL’s WHERE excludes the post whose post_status=’auto-draft’.

    Whereas, phpMyAdmin’s SQL’s WHERE needless to say, totally lacks this condition, and hence we end up with the -1 disconnect between the two ALL post counts, causing guys like me the WTH situation.

    So under the hood, the cause of the disconnect is this…

    select count(*) from `wp_posts`
    

    vs

    select count(*) from `wp_posts` where `post_status` <> 'auto-draft'