WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After upgrading to WordPress 3.1, the comment count for each post in the Posts list now shows the PHP error

Warning: number_format() expects parameter 1 to be double, string given in /wp-includes/functions.php on line 155.

This problem is definitely related to the Disqus comments plugin, which I suspect is manipulating the comments count. I see how I could fix this error by editing the WP core file /wp-admin/includes/class-wp-list-table.php and neutering the "get_comments_number()" function, but I'd rather find a solution for whatever is being manipulated in disqus.php.

Any thoughts?

share|improve this question
up vote 2 down vote accepted

After quite a bit digging, I managed to fix it without modifying any WP core files.

Essentially, Disqus usurps the comment count from WordPress and wraps it in its own with unique identifiers. Since WP is calling its own comment count when viewing the Posts lists, it's getting a string value filled with HTML rather than a plain double value with the comment count. This breaks its internal function number_format_i18n().

The fix is to edit disqus.php and have the function function dsq_comments_number($count) simply return $count. Just delete the extra HTML.

Hopefully Disqus will roll a fix out for this soon, I've had problems with how they handle comment counts in the past.

Edit: I just published a full write-up of the fix if you need more explanation: http://www.techerator.com/2011/02/fix-wordpress-3-1-and-disqus-plugin-error-when-returning-comments-count/

share|improve this answer
Thanks Evan! It worked with the fix! – user4058 Mar 19 '11 at 15:36

Thanks both for these answers. Using @Evan's or @Dan's solution works in Admin but as replied by @Evan I needed also to comment out the extra html passed by Disqus comment counts for other parts of my theme,

function dsq_comments_number($count) {
    global $post;

    if ( dsq_can_replace() ) {
        //return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">'.$count.'</span>';
        return $count;
    } else {
        return $count;

The comment count display my theme uses on home page for each post was kind of broken. It uses comments_number() wp function to supply formatting based on comment count. There is second Disqus function, dsq_comments_text($comment_text), that I also had to change,

 function dsq_comments_text($comment_text) {
        global $post;
        if ( dsq_can_replace() ) {
            return '<span class="dsq-postid"
        } else {
            return $comment_text;

I replaced the text Disqus had 'View Comments' with the var $comment_text so the strings my theme passes in the comments_number() will still get used and Disqus can still past its added html. I image that this change might not be needed for some themes if they are only using the get_comments_number(). Haven's seen that is breaks anything with Disqus either.

share|improve this answer

Your Answer


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.