Posted By

bitsculptor on 08/23/13


Tagged

comments facebook


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fhenderson


Facebook Comments for Wordpress


 / Published in: PHP
 

URL: http://wp.tutsplus.com/tutorials/the-ultimate-guide-to-implementing-facebook-comments-on-your-blog/

This is the code to add facebook comments to your wordpress site.

  1. <div id="fb-root"></div>
  2. <script>(function(d, s, id) {
  3. var js, fjs = d.getElementsByTagName(s)[0];
  4. if (d.getElementById(id)) return;
  5. js = d.createElement(s); js.id = id;
  6. js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=Your App ID Here";
  7. fjs.parentNode.insertBefore(js, fjs);
  8. }(document, 'script', 'facebook-jssdk'));</script>
  9.  
  10. <meta property="fb:app_id" content="Your App ID Here"/>
  11.  
  12. <div class="fb-comments" data-href="<?php the_permalink() ?>" data-num-posts="2" data-width="470" data-colorscheme="light" data-mobile="false"></div>
  13.  
  14.  
  15. // Get combined FB and WordPress comment count
  16. function get_full_comment_count() {
  17. global $post;
  18. $url = get_permalink($post->ID);
  19.  
  20. $filecontent = file_get_contents('https://graph.facebook.com/?ids=' . $url);
  21. $json = json_decode($filecontent);
  22. $count = $json->$url->comments;
  23. $wpCount = get_comments_number();
  24. $realCount = $count + $wpCount;
  25. if ($realCount == 0 || !isset($realCount)) {
  26. $realCount = 0;
  27. }
  28. return $realCount;
  29. }
  30. function the_full_comment_count() {
  31. $realCount = get_full_comment_count();
  32. echo $realCount;
  33. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: killjim01 on October 18, 2014

red bottom heels oakley sunglasses wholesale chi flat iron,chi hair strighteners toms wedges michael kors sale marc jacobs,marc jacobs handbags,marc jacobs bags,marc jacobs outlet moncler jackets christian louboutin,christian louboutin shoes,christian louboutin outlet fitflop coach outlet stores ugg shoes,uggs for cheap,uggs outlet,uggs for kids,ugg boots sale,uggs sale,uggs on sale,ugg gloves,ugg bailey button,ugg boots cheap,ugg moccasins,uggs canada,uggs for women,fake uggs,ugg boots,ugg uk,ugg boots on sale coach factory outlet coach cyber monday 2014,coach cyber monday,cyber monday 2014,cyber monday deals,cyber monday sales,cyber monday,louis vuitton cyber monday 2014,louis vuitton cyber monday,michael kors cyber monday 2014,michael kors cyber monday

You need to login to post a comment.