Facebook Comments for WordPress

Send Snippet To: Save this snippet to Code Collector Pro -- view all schawki's snippets
language: Other
license: Other

Code for Snippet:

<div id="fb-root"></div>
<script type="text/javascript">// <![CDATA[
(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&appId=Your App ID Here";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// ]]></script>
<meta content="Your App ID Here" /></pre>
<div class="fb-comments" data-href="<?php the_permalink() ?>" data-num-posts="2" data-width="470" data-colorscheme="light" data-mobile="false"></div>
// Get combined FB and WordPress comment count
function get_full_comment_count() {
 global $post;
 $url = get_permalink($post->ID);
 $filecontent = file_get_contents('https://graph.facebook.com/?ids=' . $url);
 $json = json_decode($filecontent);
 $count = $json->$url->comments;
 $wpCount = get_comments_number();
 $realCount = $count + $wpCount;
 if ($realCount == 0 || !isset($realCount)) {
 $realCount = 0;
 return $realCount;
function the_full_comment_count() {
 $realCount = get_full_comment_count();
 echo $realCount;
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 538
Date Added: 2015-01-12 11:54:12
Last Modified: 2015-01-12 04:54:26

Web Analytics