WordPress.org

Forums

The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Facebook Comments
How to combine wordpress and facebook comments counts (4 posts)

  1. miss_monster
    Member
    Posted 2 years ago #

    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: http://wp.tutsplus.com/tutorials/the-ultimate-guide-to-implementing-facebook-comments-on-your-blog/

    http://wordpress.org/plugins/facebook-comments-plugin/

  2. breathelifein
    Member
    Posted 2 years ago #

    Thank you! I was just looking for that. Cheers!

  3. 437105
    Member
    Posted 2 years ago #

    What does "And than, this to your template" mean? Which file exactly?

    Doesn't work for me for some reason. FB comment count is not displayed for an article. I would also like to remove default WP comment system, replacing it with FB one, but there's no clear guide for that anywhere.

  4. samazgor
    Member
    Posted 1 year ago #

    I was developing a site where facebook comments are enabled. But my client wants to go back to default wp comment system, and also wants to merge those fb comments with wp comments. What is the solution ?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Facebook Comments
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.