社会化评论系统,相信绝对大多数人都知道并且使用过。之前使用过畅言,友言,对着俩货,不作过多评论,单纯从外观上,友言就已经远远逊色于畅言和多说,相关对比参数不再赘述,总之一句话,哪个好用,哪个好看用哪个。
多说总之加载速度方面和外观方面都非常不错,简洁不罗嗦,总比畅言卡的一逼强。使用多说,注册账号之后,开始部署通用代码,WordPress 构建的站点原则上尽量不使用多说的 wp 插件,你懂的。 woocommerce 插件构建的电子商务商品页面中部署多说。

找到模板的 description.php 文件 (具体路径:ext/woocommerce/templates/single-product/tabs/)

description.php 中在函数

<span style="font-family:Microsoft YaHei;font-size:14px;"><?php the_content(); ?></span>

商品详情页输出之后去加载多说。

多说的通用代码如下:

<!-- 多说评论框 start -->
	<div  data-thread-key="请将此处替换成文章在你的站点中的 ID" data-title="请替换成文章的标题" data-url="请替换成文章的网址"></div>
<!-- 多说评论框 end -->
<!-- 多说公共 JS 代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"kejianet"};
	(function() { var ds = document.createElement('script'); ds.type = 'text/javascript';ds.async = true; ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js'; ds.charset = 'UTF-8'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
<!-- 多说公共 JS 代码 end -->
data-thread-key="请将此处替换成文章在你的站点中的 ID" data-title="请替换成文章的标题" data-url="请替换成文章的网址"

这三个参数是需要用户去用变量去替换的。如果不替换参数,单个页面中的评论将不能区分显示!

具体代码如下:

<span style="font-family:Microsoft YaHei;font-size:14px;"><?php the_content(); ?>
<br/>
<!-- 多说评论框 start -->
	<div  data-thread-key="<?php the_ID(); ?>"  data-title="<?php echo curPageTitle(); ?>" data-url="<?php echo curPageURL(); ?>" ></div>
<script type="text/javascript">
var duoshuoQuery = {short_name:"kejianet"};
	(function() { var ds = document.createElement('script'); ds.type = 'text/javascript';ds.async = true; ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js'; ds.charset = 'UTF-8'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
<?php
//获取当前页面 URL
function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL;
}
//获取当前页面标题
function curPageTitle()
{ $title = get_post(get_the_ID())->post_title; return $title;
} ?>
<!-- 多说评论框 end --></span>

三个变量即完成了配置。

多说后台则显示如下:

最后一个问题:切记你加入多说通用代码的页面编码必须是 UTF-8,否则 post 过去的参数后台显示乱码!