DWalk
DWalk

Reputation: 49

My facebook like button is not showing up

I looked at previous asked questions about the facebook like button and didnt see anything that was wrong with my code. Here is what I have:

<body>

 <div id="fb-root"></div>
 <script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];
   if (d.getElementById(id)) return;
   js = d.createElement(s); js.id = id;
   js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
   fjs.parentNode.insertBefore(js, fjs);}
 (document, 'script', 'facebook-jssdk'));</script>


</body>

Upvotes: 3

Views: 16242

Answers (4)

nikitahl
nikitahl

Reputation: 446

Adding version to the url js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11"; helped in my case.

Upvotes: 0

Thulis
Thulis

Reputation: 51

I know topic is old but still coming up in searches. Here's the initialization code I used:

 (function(d, s, id){
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

Important:

  1. By default Facebook auto-configuration tool (https://developers.facebook.com/docs/plugins/follow-button) does not prepend "HTTPS" when exporting the js.src element.
  2. If testing this on localhost host you will run into problems with the button visibility (c.f. v2.9) Either use a https tunnel service such as ngrok or deploy to valid https server.

Upvotes: 1

Yovav
Yovav

Reputation: 2777

Had the same problem, once I published the page, the like buttons showed up

facebook page : settings : Page Visibility : Page published

(the page was "unpublished" by default even after I did publish it for the first time)

Upvotes: 2

Anvesh Saxena
Anvesh Saxena

Reputation: 4466

After adding the code for initializing the Facebook's Javascript SDK you also have to add the code to display the Like button at the required place. The generic code for it is

<div class="fb-like" data-send="true" data-width="450" data-show-faces="true">
</div>

If you want you can further customize it by checking documentation here.

Upvotes: 4

Related Questions