Глобальная переменная $ post здесь не установлена.Как мне это установить?
function fb_comment_count($link = 'link') {
global $post;
$url = 'https://graph.facebook.com/';
$posturl = get_permalink($post->ID);
$url .= $posturl;
$filecontent = wp_remote_retrieve_body(wp_remote_get($url, array('sslverify'=>false)));
$json = json_decode($filecontent);
$count = $json->comments;
if ($count == 0 || !isset($count)) {
$count = 0;
}
$comments = $count;
if ($count == 1) {
$comments .= '';
}
elseif ($count == 0) {
$comments = '0';
}
elseif ($count > 1) {
$comments .= '';
}
if ($link == 'nolink') {
return $comments;
}
else {
return '<a href="'.$posturl.'#comments" title="Comments for '.$post->post_title.'">'.$comments.'</a>';
}
}