Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. function total_number_comment() {
  2.  
  3. global $post;
  4. $url = get_permalink($post->ID);
  5.  
  6. $filecontent = file_get_contents('https://graph.facebook.com/?ids='.$url);
  7. $json = json_decode($filecontent);
  8.  
  9. $fb_count = $json->$url->comments;
  10. if ($fb_count == 0 || !isset($fb_count)) {
  11. $fb_count = 0;
  12. }
  13. $wp_count = (int)get_comments_number();
  14.  
  15. echo $fb_count + $wp_count;
  16. }
  17.  
  18. <script>
  19. window.fbAsyncInit = function() {
  20. FB.init({
  21. appId : 'ID',
  22. xfbml : true,
  23. version : 'v2.4'
  24. });
  25. };
  26.  
  27. (function(d, s, id){
  28. var js, fjs = d.getElementsByTagName(s)[0];
  29. if (d.getElementById(id)) {return;}
  30. js = d.createElement(s); js.id = id;
  31. js.src = "//connect.facebook.net/en_US/sdk.js";
  32. fjs.parentNode.insertBefore(js, fjs);
  33. }(document, 'script', 'facebook-jssdk'));
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement