0

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?

  • if you want to make the icon inside author's avatar. you need a css to do it. – ucon89 Jul 3 '15 at 8:49
2

The function you're looking for is get_avatar - you should put in something like this:

<?php echo get_avatar( get_the_author_meta( 'ID' )); ?>
| improve this answer | |
  • Hi there is an error it doesn't work. I substitute the code with the code you gave me, it shows error. – user74285 Jul 3 '15 at 8:28
  • The function should output an img element. How did you use it exactly? – Lucian Davidescu Jul 3 '15 at 8:55
  • instead how do you put the buddypress avatar inside the div or i-tag? – user74285 Jul 3 '15 at 9:38
  • I dont know if the buddypress avatar is fetched with the same function, I suppose it should. Did you try it like this? <i><?php echo get_avatar( get_the_author_meta( 'ID' )); ?></i> – Lucian Davidescu Jul 3 '15 at 10:41
  • still error let me paste the whole code: $output .= '<div class="pl-detailcnt">'; if($this->pw_grid_author=='no') { $output.=' <div class="pl-postmeta" > <i class="fa fa-user"></i><span>'.get_the_author().'</span></div>'; } – user74285 Jul 3 '15 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy