Philippians Underground Recycle Bucket
Would you like to react to this message? Create an account in a few clicks or log in to continue.

在评论中启用Gravatars / 頭像

向下

在评论中启用Gravatars / 頭像 Empty 在评论中启用Gravatars / 頭像

發表  Sundog 周一 10月 06, 2008 12:55 pm

Gravatars是由Gravatars.com提供的评论者头像服务,用户在留言评论后会在对应的评论中出现代表其的头像[如果主题支持Gravatars]。很多主题在设计和发布的时候是不支持Gravatars的,所以这里给出添加Gravatars的方法。打开您主题文件中的comments.php文件,找到下面这行代码:-

<?php comment_text() ?>

用下面这段代码替代上面的代码:-

<div class="gravs">
<?php if (get_bloginfo('version')>=2.5)
echo get_avatar( $comment->comment_author_email, $size = '50', $comment->comment_author_link);?>
<?php comment_text() ?>
</div>
<br clear="all" />


添加上面的代码后您使用的主题便支持Gravatars了。现在,让我们在style.css中添加一些CSS样式让Gravatars看起来更棒:-

.gravs {margin-top:20px;}
.avatar {float:left; margin-right:5px; margin-bottom:5px; padding:3px; border:1px solid #999999;}


好的,现在去检查您的主题,您会发现评论内容旁边出现了评论者的头像。

Chada补充:Gravatars可以在“后台 - 设置 - 评论 / Dashboard - Setting - Comments”的页尾进行设置开启或关闭,同时,您还可以为没有申请Gravatars的评论者设定默认头像。
Sundog
Sundog
拾荒阿伯
拾荒阿伯

文章數 : 104
注冊日期 : 2008-09-30
年齡 : 45
來自 : Taipei, Taiwan

http://philippians.chinarenluntan.info

回頂端 向下

回頂端


 
這個論壇的權限:
無法 在這個版面回復文章