开发者

How to use current URL as Href in facebook comments?

开发者 https://www.devze.com 2023-03-24 06:02 出处:网络
I\'m using the facebook comments plugin, I believe I was using it withou开发者_如何学编程t setting an href and it automatically used the current url as href but it stopped working saying I MUST set hr

I'm using the facebook comments plugin, I believe I was using it withou开发者_如何学编程t setting an href and it automatically used the current url as href but it stopped working saying I MUST set href.

How do I set HREF as the current URL so I get different comments on each page?

<fb:comments href="" num_posts="2" width="500" style="padding-top: 20px; margin-top: 20px; border-top: 1px dotted grey;"></fb:comments>

Thanks


If you are using wordpress (my guess) you should enter <?php the_permalink(); ?> in the fb:comments:

<fb:comments href="<?php the_permalink(); ?>" num_posts="2" width="500" style="padding-top: 20px; margin-top: 20px; border-top: 1px dotted grey;"></fb:comments>

if not try making the URL

$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https'; // get the protocol
$host = $_SERVER['HTTP_HOST']; // host name
$script = $_SERVER['SCRIPT_NAME']; // script path
$params = $_SERVER['QUERY_STRING']; // params
$uri = $_SERVER['REQUEST_URI']; // full script path with params if you are not interested in protocol or host name

so

$currentUrl = $protocol . '://' . $host . $script . '?' . $params;
// or
$currentUrl = $protocol . '://' . $host . $uri;

<fb:comments href="<?php echo $currentUrl; ?>" num_posts="2" width="500" style="padding-top: 20px; margin-top: 20px; border-top: 1px dotted grey;"></fb:comments>
0

精彩评论

暂无评论...
验证码 换一张
取 消