"wordpress添加facebook评论代码-Add Facebook Comments plugin code to wordpress"

Published on Aug. 22, 2023, 12:07 p.m.

插件实现此处不做介绍,有很多可以选择,安装也很简单.

wordpress添加facebook评论代码到single.php

首先到https://developers.facebook.com/docs/reference/plugins/comments/获取如下代码

<div id=”fb-root”></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/zh_CN/all.js#xfbml=1&appId=399985616728633”;
  fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));</script>

<div class=”fb-comments” data-href="http://example.com” data-width=”450” data-num-posts=”2”></div>
修改后适用于wordpress,到single.php替换掉评论代码

<div id=”fb-root”></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/zh_CN/all.js#xfbml=1&appId=399985616728633”;
  fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));</script>
**<div class=”fb-comments” data-href=”<?php the_permalink(); ?>” data-width=”450” data-num-posts=”2”></div>

这样能够实现每篇文章都会有相应的评论,而不是直接从facebook获取的代码是针对整个网站的.Good luck!but  Chinese…**

These post may help you:

Facebook Comments WordPress Plugin