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>
精彩评论