I’ve used many ways of getting the comment count of the facebook comment plugin.
But none works.. sometimes it works and after an refresh its brokan again.

This is what i’ve tryed.

    <div id="fb-root"></div>
    <script>(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/nl_NL/sdk.js#xfbml=1&version=v2.9&appId=xxxxxxxxxx";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

<span class="info"><span class="fb-comments-count" data-href="<?php echo the_permalink(); ?>"></span></span>

<div class="fb-comments-count" data-href="<?php echo the_permalink(); ?>"></div>

I even found an wordpress function but that also doesnt work.

function fb_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;
if ($count == 0 || !isset($count)) {
    $count = 0;
echo $count;}

I’m really lost here.. who can I get something simple as this working?
I’m using wordpress and php 7.1

Read more here: Facebook comment count doesn’t work


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: