[wp-testers] incorrect post counts

Ryan Boren ryan at boren.nu
Sat Feb 9 07:09:10 GMT 2008


On Thu, Feb 7, 2008 at 1:47 PM, Lloyd Budd <lloydomattic at gmail.com> wrote:
> On Feb 7, 2008 1:34 PM, ]V[orlock Zernebock <morlockz at gmail.com> wrote:
>  > When I run the query directly in MySQL I got the correct number. All my old
>  > published posts are with that status in MySQL.
>  >
>  > Here you have the results to compare against dashboard numbers:
>  >
>  > You have 1 posts, 12 pages, 1 draft, contained within 35 categories and 1
>  > tags.
>
>  Interesting results. As those 1s are the first digit in the #...
>  leaves me wondering. So the next step would be to add debug to the
>  wp-admin/index.php to see that variables are being assigned the right
>  value. If they are are, could it be number_format_i18n function? That
>  is where I would look next.

Fixed.  wp_count_posts() returns 1481, for example.
number_format_i18n() converts this to 1,481.  1,481 is not an integer
because of the comma, so passing it to sprintf with a %d format casts
it to 1.  Changing to %s fixes it.

Ryan


More information about the wp-testers mailing list