Quantcast
Channel: SayBlog.Me » WordPress技巧
Viewing all articles
Browse latest Browse all 8

不用插件,将Google +评论功能整合到WordPress

$
0
0

Google +的评论系统简洁又好用,如果你喜欢,可以将它整合到自己的WordPress博客中去。这里介绍的方法是免插件的,相当简单。

不用插件,将Google +评论功能整合到WordPress

将当前主题文件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>

就拿Twenty Eleven主题做个例子,我将它的comments.php文件中的代码修改为:

<?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>

结果评论部分变成如下图:

google plus commenting

评论区的长度是可以修改的,只需改变代码中data-width的值即可,如将“800”修改为“600”。

Via Wpstuffs


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images