Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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?

share|improve this question
2  
You seem to have found an answer in wp-hackers list... Would you mind sharing the answer here? –  brasofilo Jun 22 '12 at 19:12
    
will do. if you be patient, you do not have to worry about these things... if you look at some of my old answers, i answer the questions that i myself asked for the other's benefit. these things are a matter of time.. stay cool, we'll do it. –  Average Joe Jun 22 '12 at 23:34
    
Downvote removed. I raised the flag as it would keep anyone from researching for something that already had tons of feedback at wp-lists... Thanks for reporting back! –  brasofilo Jun 23 '12 at 20:47
add comment

1 Answer

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'
share|improve this answer
    
+1 for posting your own answer. –  Brian Fegter Sep 25 '12 at 9:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.