函数 returns post URL 而不是检索 Facebook Graph API 数据

Function returns post URLs rather than retrieving Facebook Graph API data

require('../wp-blog-header.php');
query_posts('&showposts=-1&order=ASC');

while (have_posts()) : the_post();

        $url = the_permalink();
        $json = file_get_contents( 'https://graph.facebook.com/fql?q=SELECT%20like_count,%20total_count,%20share_count,%20click_count,%20comment_count%20FROM%20link_stat%20WHERE%20url%20=%20%27' . $url . '%27' );
        $json_data = json_decode($json, false);
        echo $json_data->data[0]->total_count;
        echo '<br>';

    endwhile;

以上代码不是 return 总分享数,而是 return post 个 URL。

如何使每个 post 的 return 成为 total_count 值?我怀疑第 6 行需要在下一行执行任务之前首先 return URLs..

此致,

谢谢!

WordPress 开发网络中有人向我指出了这一点:

the_permalink(); 没有 return 永久链接,它会打印它,所以我应该改用 get_the_permalink();

$url = get_the_permalink();