admin管理员组文章数量:1313121
I'm using WordPress with bbPress and Gravatar for user avatars. I want to display the user's avatar next to their topic. I'm using:
echo get_avatar( get_the_author_meta( 'ID' ), 32 );
Which get's me this:
I know that my author image is set because I set it myself.
I'm using WordPress with bbPress and Gravatar for user avatars. I want to display the user's avatar next to their topic. I'm using:
echo get_avatar( get_the_author_meta( 'ID' ), 32 );
Which get's me this:
I know that my author image is set because I set it myself.
Share Improve this question edited Dec 26, 2016 at 16:47 Jami Gibbs 7694 silver badges13 bronze badges asked Dec 26, 2016 at 12:37 ouqas mohamedouqas mohamed 11 silver badge8 bronze badges 1- Are you working with bbPress or something? If so, you should update your question to be more specific. – Jami Gibbs Commented Dec 26, 2016 at 13:15
1 Answer
Reset to default 1The get_avatar
function is a pluggable function with it's first parameter being either the user's ID or email.
You're using get_avatar with get_the_author_meta('ID')
which should give you the ID of the current user within the Loop.
From the Codex
If used within The Loop, the user ID need not be specified, it defaults to current post author. A user ID must be specified if used outside The Loop.
get_the_author_meta( string $field = '', int $user_id = false )
So it would be redundant using get_avatar
with get_the_author_meta('ID')
, you can just specify the ID directly:
echo get_avatar( USER_ID, 32 );
本文标签: bbpressAvatar picture does not display when using getavatar
版权声明:本文标题:bbpress - Avatar picture does not display when using get_avatar 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741947446a2406504.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论