Facebook Share button and that little annoying behaviour with zero counts

The new Facebook Share button is very cool and offers a new insightful information about your posts: the share count.
Alas, when no one has yet shared your post, the count balloon disappears in thin air. This give you layout headaches, because the widget doesn’t fill a fixed area in the page.
jQuery to the rescue! I wrote this simple code to fix the problem and show a neat “0” count beside the post. Thought I’d share for someone out there in need :)

jQuery(document).ready(function(){
  jQuery("span.fb_share_no_count").each(function(){
    jQuery(this).removeClass("fb_share_no_count");
    jQuery(".fb_share_count_inner", this).html("0");
  });
});

Comments

Hi, I’m having the same problem even if the count is greater than 0. Seems like other’s have the same problem: http://bugs.developers.facebook.com/show_bug.cgi?id=8032 Do you know of a way to get that count w/o making a restserver call to the fb api? Thanks so much for this!

So…where does this code go? Somewhere within the button script?

Thanks a lot!

Great fix for share. Can you please figure out the same fix for the Facebook “Like” button?

Thanks, I’ve been looking for this. In my theme directory, I created a file called custom.js, paste your code there, have it called from the theme’s .info file, and everything is good to go!