2012-04-11 77 views
0

我已经手动安装了Facebook的评论,但不断收到commentbox下面的错误消息:Facebook的评论不会接受让我的WordPress博客永久

警告:http://invalid.invalid/?php%20echo%20get_permalink();%20>不可达?

我把这个在我的头:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"> 

和:

<meta property="og:title" content="<?php echo get_the_title(); ?> "/> 
<meta property="og:url" content="<?php echo get_permalink(); ?>"/> 
<meta property="og:image" content="xxxxxxxxx"/> 
<meta property="og:description" content="<?php 
    while(have_posts()):the_post(); 
    $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", get_the_excerpt()); 
    echo apply_filters('the_excerpt_rss', $out_excerpt); 
    endwhile; ?>"/> 
<meta property="fb:app_id" content="xxxxx"> 
<meta property="fb:admins" content="xxxxx"/> 

在我的single.php文件中添加此:

<?php if (in_category('randomposts')) { 
    echo '<div></div>'; 
} else { 
echo '<div class="fb-comments" data-href="<?php echo get_permalink(); ?>" data-num-posts="5" data-width="640"></div>'; 
} 

?> 

我检查我的网站在facebook调试器/ linter并没有问题出现在那里。评论框显示在我的页面上,但该警告正在扰乱我。您可以分享到Facebook,但它会显示http://invalid.invalid作为网址。 我发现问题是我的single.php文件中的'echo get_permalink'。 当我输入我的主页网址时,没有任何警告和一切功能,因为它应该共享我的主页网址而不是发布网址。

下面是一个例子:

http://www.itrainmymind.com/this-is-a-tespost/ 

回答

2

你有两个echo的存在。你想要的是

echo '<div class="fb-comments" data-href="', get_permalink() ,'" data-num-posts="5" data-width="640"></div>'; 
+0

谢谢scibuff,它工作! – napionder 2012-04-11 16:32:33

0

与Facebook,你必须在WordPress的single.php页面

<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url;?> 

使用该超链接只是使用默认的代码

<?php echo get_permalink(); ?> 

将不起作用

相关问题