admin管理员组文章数量:1290938
How do I get the authors avatar? Buddypress plugin or any plugin.
I have found this inside my PHP code:
"<i class="fa fa-user"></i><span>'.get_the_author().'</span></div>';"
It shows a small image before the author's name, I wanted to change the fa fa-user
into author's avatar or buddypress avatar.
What will be the script to do that?
How do I get the authors avatar? Buddypress plugin or any plugin.
I have found this inside my PHP code:
"<i class="fa fa-user"></i><span>'.get_the_author().'</span></div>';"
It shows a small image before the author's name, I wanted to change the fa fa-user
into author's avatar or buddypress avatar.
What will be the script to do that?
Share Improve this question edited Jul 2, 2015 at 22:10 gmazzap 46.3k6 gold badges95 silver badges147 bronze badges asked Jul 2, 2015 at 21:54 user74285user74285 1- if you want to make the icon inside author's avatar. you need a css to do it. – ucon89 Commented Jul 3, 2015 at 8:49
2 Answers
Reset to default 7The function you're looking for is get_avatar
- you should put in something like this:
<?php echo get_avatar( get_the_author_meta( 'ID' )); ?>
There are two methods to get user avatar in WordPress.
1st Method:
<?php
if (get_the_author_meta('email')) {
echo get_avatar(get_the_author_meta('email'), '60');
}
?>
2nd Method:
<?php echo get_avatar(get_the_author_meta('ID')); ?>
3rd Method
<picture>
<source srcset="<?php print get_avatar_url(get_current_user_id(), ['size' => '51']); ?>" media="(min-width: 992px)" />
<img src="<?php print get_avatar_url(get_current_user_id(), ['size' => '40']); ?>" />
</picture>
本文标签: How to get authors avatar
版权声明:本文标题:How to get authors avatar 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741511063a2382608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论