How to combine wordpress and facebook comments counts
-
Well, I wass looking for way to display combiend fb and wp comments.
I’ve found a way and I think you can find it usefull.Insert this in functions.php:
function 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; }
And than, this to your template:
<?php if (full_comment_count()==0) { ?> <?php } else { ?> <?php echo full_comment_count(); ?> <?php } ?>
That’s it. Thanks to: https://wp.tutsplus.com/tutorials/the-ultimate-guide-to-implementing-facebook-comments-on-your-blog/
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to combine wordpress and facebook comments counts’ is closed to new replies.