Question

I am developing a website which has a Blog, with multiple articles and URLs. I need to insert Facebook Like Button with auto-detect URL. Is that possible?

Tried this CODE, but shows an error in frontend.

<div class="itemFacebookButton">
            <div id="fb-root"></div>
            <script type="text/javascript">
                (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>
            <div class="fb-like" data-href="<?php echo $this->item->link; ?>" data-width="450" data-layout="button_count" data-show-faces="false" data-send="true"></div>
        </div>
Was it helpful?

Solution

Facebook has a tool for this or am I missing part of the question?

https://developers.facebook.com/docs/reference/plugins/like/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top