0
我succeded通過這個功能來獲取Facebok的評論數:的WordPress + Facebook的評論除了(PHP所需要的知識)
<?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;
}
;?>
而且我把它叫做:
<?php fb_comment_count();?>
現在我該怎樣添加它到此代碼:
<?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments'), '', __('Comments Closed')); ?>
這樣WordPress就可以在一個數字中顯示WP和FB註釋的數量。
非常感謝大家!
哇,你是偉大的,這就像一個魅力,你只是忘記$ fb_comments – OriginalEXE 2012-04-27 14:55:12
前面非常感謝你,我在債務:) – OriginalEXE 2012-04-27 14:55:25