Fix WordPress comment count error caused by Disqus plugin

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
May 28, 2011

Disqus for WordPress is a great plugin for those who want to integrate a better way of adding comments to their blogs. With Disqus, you can allow your visitors to easily post comments through their Facebook or Twitter accounts. Disqus perfectly syncs with WordPress comment system and the comment on your database is also synced with Disqus’ server. But with the latest version of WordPress i.e. WordPress 3.1, Disqus has some issues showing the comment counts for the post. Here is how you can fix comment count error in WordPress 3.1 when Disqus plugin is used.

After upgrading to WordPress 3.1, you would encounter a strange error in the post list area instead of the comment count. This would happen only if you have Disqus plugin for WordPress installed. The error looks something like this:

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

Disqus comment system

This error occurs because Disqus’ comment count system uses its own value for counting comments that breaks WordPress’s default function number_format_il8n(). This function expects the comment number value to be a double instead of a string. So, we’ll have to edit a file on Disqus plugin folder.

Open the file /wp-content/plugins/disqus-comment-system/disqus.php. Now find the following line of code on your text editor.

[code]function dsq_comments_number($count)[/code]

Your code will look something like this:

[code]
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>’;
} else {
return $count;
}
}
[/code]

Simply replace the above code with the following.

[code]
function dsq_comments_number($count) {
global $post;

return $count;
}
[/code]

This will do the trick to fix error in comment count on WordPress 3.1 due to Disqus plugin.

You may also like...

  • Chris Richard

    Hello Everyone,

    Are you financially squeezed? Do you seek Loans to pay off credits and
    debts? Do you seek finance to set up your own Business? Are you in need of
    private or Business Loan for various purposes? Do you seek loans to carry
    out Large Projects? Secure a Loan from us today and start up with something
    rewarding. Our transaction is 100% guaranteed as we also ensure a cordial
    relationship with our clients. We offer Loans with no credit Checks, No
    collateral, Easy steps, fast funding and low interest rate of 2%. Why
    remain in a financial breakdown?
    Contact us today via Email: rolandfredrickloaninsuranceplc@gmail.com

  • tina toth

    we offer 5000 to 250,000 Dollars to pay their bills
    as well as solve their other Financial needs?
    Get a loan from our firm only to the 2% interest rate,
    kindly contact us today for your loan.
    expansioncapital112@gmail.com