WordPress + Facebook comments addition (php knowledge needed)
- by user1356223
I succeded to fetch Facebok comments number via this function:
<?php
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;
}
;?>
And I call it with:
<?php fb_comment_count();?>
Now how do I add it to this code:
<?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments'), '', __('Comments Closed') ); ?>
so that WordPress shows number of WP and FB comments together in one number.
Thank you very much to everyone!