0

I have a post with 2 buttons, share and like:

<input class="fb-like contact-submit" data-href="<?php the_permalink(); ?>" type="button" value="LIKE">
<input class="fb-share-button contact-submit" data-href="<?php the_permalink(); ?>" type="button" value="SHARE">

function permalink in data-href print full url to this post(WordPress function).

I added javascript after opening body tag:

<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/pl_PL/sdk.js#xfbml=1&version=v2.3";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

And it's not workig, nothing's happen 'on click'.

Why this code is not working? I read that to do this creating Facebook app is not needed. What's wrong?

Much thanks for everyone.

Robson
  • 1,207
  • 3
  • 21
  • 43
  • 2
    Don’t use `input` elements for those, use `div`. (The JS SDK will try to append an `iframe` to the elements with those classes, and that will fail for an `input`, because those can not have children.) – CBroe Apr 08 '15 at 12:05
  • @CBroe Thank You so much for help, but what if I want show my custom buttons ? Original code with div show default fb buttons, how i can change that ? – Robson Apr 08 '15 at 12:23
  • If you want to use FB social plugins, then you’re stuck with the limited styling configuration options they provide. If you want something else, then you need to implement the functionality yourself. For sharing that is pretty easy using the Share Dialog; liking stuff is more limited, you can try with the `og.likes` Open Graph action. – CBroe Apr 08 '15 at 12:26
  • As CBroe already told you, you're basically breaking the FB Like button integration. Please see [this](http://stackoverflow.com/questions/9493988/how-to-trigger-facebook-like-button-from-custom-button) – curveorzos Apr 15 '15 at 00:00

0 Answers0