Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Rajat Varlani

    (@the_champ)

    Hi,
    Sorry, there isn’t any shortcode for FB Commenting currently.
    For now, you can place following code where you want to enable Facebook Commenting, after switching post/page editor to “Text” mode.

    <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/sdk.js#xfbml=1&version=v2.0";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    <div class="fb-comments" data-href="WEBPAGE_URL" data-numposts="5" data-colorscheme="light"></div>

    Replace WEBPAGE_URL in above mentioned code with the webpage url on which you want to comment.

    Thread Starter amenwolf

    (@amenwolf)

    Thanks for the reply.

    … Or you could make your own shortcode by putting the following into your theme’s “functions.php”:

    function my_fb_social_commenting () {
    echo '<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/sdk.js#xfbml=1&version=v2.0";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    <div class="fb-comments" data-href="https://"' . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'].'" data-numposts="5" data-colorscheme="light"></div>';
    }
    add_shortcode('my_fb_comments','my_fb_social_commenting');

    Then just use [my_fb_comments] wherever you want.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Short codes for FB Commenting’ is closed to new replies.