I'm using user-avatar, and I want to show user icon in the post meta data. http://wordpress.org/plugins/wp-user-avatar/

I'm writing like this.

<?php the_author_posts_link(); ?> <?php echo get_avatar(); ?>

It shows only default "nobody" avatar.

If I write like <?php echo get_avatar("myemail@example.com"); ?>, then it shows my avatar through user-avatar plugin.

So if I can get the author's emails, it works all fine.

I tried to get the email by <?php the_author_meta('user_email'); ?>. But it doesn't return the email, but it outputs directly.

I'm stuck now. How can I set user avatar in post meta area?


Use get_the_author_meta(), this function returns data, it doesn't display it. For example:--

<?php $user_email = get_the_author_meta('user_email'); ?>

For more information check it in the codex

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.