I have used the below function in my functions.php file in WordPress which is used to call the specified subqueries to show up a particular link's total facebook shares, likes, comments etc.
function fb_echoes($type) {
global $post;
$url = get_permalink($post->ID);
$fbconfig['appid' ] = "1427040634231404";
$fbconfig['secret'] = "49a95c1eb6f7862caa8f66b04c87318d";
include_once "facebook.php";
$facebook = new Facebook(array(
'appId' => $fbconfig['appid' ],
'secret' => $fbconfig['secret'],
'cookie' => true
));
$fql = "SELECT url, normalized_url, share_count, like_count, comment_count, total_count, commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url = '".$url."' ";
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
return $fqlResult[0][$type];
}
To show the number of facebook comments anywhere in the page, I'm using this code:
<?php echo fb_echoes(commentsbox_count) ?>
I've already disabled the default WP comments but the small count icon on the posts and homepage shows the counts of WP comments. I want to show FB comments count over there. The below code displays the default comments count:
function it_get_comments($args) {
extract($args);
$tooltip = '';
$comments = get_comments_number($postid);
$label_text=__(' comments',IT_TEXTDOMAIN);
if($comments==1) $label_text=__(' comment',IT_TEXTDOMAIN);
if(empty($tooltip_hide)) $tooltip = ' info-bottom';
$out='<span class="metric' . $tooltip . '" title="'.__('Comments',IT_TEXTDOMAIN).'">';
if($comments>0 || $showifempty) {
if($anchor_link) '<a href="#comments">';
if($icon) $out.='<span class="icon icon-commented"></span>';
$out.='<span class="numcount">' .$comments;
if($label) $out.=$label_text;
$out.='</span>';
if($anchor_link) '</a>';
}
$out.='</span>';
return $out;
}
How do I call the commentsbox fql subquery into this function and override the WP comment counts over FB comments count!?