所以我想到的是根据他们有多少 Facebook 评论显示一个列表,其中包含最受欢迎的帖子。我已经设法制作了一个函数来计算基于 facebook 图表的帖子有多少评论,但我遇到了查询问题:
function fb_comment_count() {
global $post;
$url = get_permalink($post->ID);
$filecontent = file_get_contents('http://graph.facebook.com/?ids=' . $url);
$json = json_decode($filecontent);
$count = $json->$url->comments;
if ($count == 0 || !isset($count)) {
$count = 0;
} ?>
<?php if ($count == 0) { ?>
<span>No comment</span>
<?php } elseif ($count == 1) { ?>
<span>One Comment</span>
<?php } elseif ($count > 1 ) { ?>
<span><?php echo $count; ?> Comments</span>
谢谢!