Share facebook button displaying wrong information in “box_count”

Posted on

Question :

In a wordpress-based project I’m working on, I have a modal that dynamically receives various information coming from a post-loop.

This modal serves as a kind of “Preview” the complete post.

Within this modal there must be sharing options (Facebook, + g, twitter, etc.).

The URLs that will be used by the share buttons are the urls of the full post. To pass the values dynamically I use JavaScript.

So far, everything works fine. The problem is that when you share the post, the facebook button counter does not increase. To view the current share number, you need to close the modal and open it again.

I think it is necessary to reopen the modal due to the use of FB.XFBML.parse (); to update the url.

I wonder if there is a way to reload the button to display the correct information without closing the modal? As a callback function to reload the facebook button when the user shares the content?

Part of the html code of the modal:

    (function(d, s, id) {
       var js, fjs = d.getElementsByTagName(s)[0];
       if (d.getElementById(id))
           js = d.createElement(s);
  = id;
           js.src = "//";
           fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
     <fb:share-button id="fb_share_quick" href="#" layout="box_count" width="58"></fb:share-button>

Part of the javascript code that changes the url:

jQuery('.showPreview').on('click', function() {
    jQuery('fb:share-button').attr('href', '');

Can anyone give me any tips on how I can solve this?


Answer :

I do not know if I understood correctly but from what I realized you want to show sharing buttons on the frontpage for the proper publications / posts is this?!

use this instead of loading more JS into your wordpress site:


<a class="random-class-button" href="<?php the_permalink() ?>" target="_blank"><img title="Facebook" alt="Facebook" width="38" height="38" src=""></a>


/* background:green; personaliza a class à tua maneira */


Leave a Reply

Your email address will not be published. Required fields are marked *