听说WordPress 2.5 已经将 Gravatar 集成了进来了.但是一直不知道怎么用.通过伟大的GOOGLE,终于在冰仔那里找到方法了.
只需要在模板中添加的,只有这几行代码:
<?php if (function_exists(’get_avatar’)) { ?>
<div class=”gravatar”><?php echo get_avatar(get_comment_author_email(),’64′); ?></div>
<?php } ?>
甚至你可以去掉这个 div 容器,干脆一行代码:
<?php if (function_exists(’get_avatar’)) { echo get_avatar(get_comment_author_email(),’64′); } ?>
稍微解释一下,用来显示 Gravatar 头像的函数是 get_avatar(),get_comment_author_email() 放在留言 loop 中得到留言者的 email 地址,这个很关键,Gravatar 头像基本上全靠这个 email 了,后面的 ‘64′ 表示头像显示的宽度、高度均为 64px,最大为 80px。



0 users responded to this post
1 Pingback & Trackback On This Post
Leave Your Comments Below