1

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?

3
  • 3
    You seem to have found an answer in wp-hackers list... Would you mind sharing the answer here?
    – brasofilo
    Jun 22, 2012 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. Jun 22, 2012 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, 2012 at 20:47

1 Answer 1

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'
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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