2013年4月22日 | | 标签: ,

最近看到了一篇不错的教程,觉得很实用,当然由于种种原因 Google + 在国内一直是镜中月水中花,不过也不妨碍我们跳出墙去看看外面的风景,最近Google+的势头一直很猛,大有山雨欲来风满楼的态势,这篇教程就来讲述一下如何简单的不安装插件的方式把Google+的评论集成到WordPress上。

原教程地址:http://www.wpstuffs.com/implement-google-plus-commenting-to-wordpress-blog-without-using-plugin/

方法如下:

用以下代码替换默认comments.php里边的部分代码:

<script src="https://apis.google.com/js/plusone.js">
</script>

<div class="g-comments"
data-href="<?php the_permalink(); ?>"
data-width="800"
data-first_party_property="BLOGGER"
data-view_type="FILTERED_POSTMOD">
</div>

你可以改变data-width=”800″这个参数来改变评论框的宽度。

以下为插入上边代码后的完整代码效果,以WordPress的Twenty Eleven模版为例说明:

<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to twentyeleven_comment() which is
* located in the functions.php file.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
?>

<script src="https://apis.google.com/js/plusone.js">
</script>

<div class="g-comments"
data-href="<?php the_permalink(); ?>"
data-width="800"
data-first_party_property="BLOGGER"
data-view_type="FILTERED_POSTMOD">
</div>