Add Author avatar and bio to post WordPress

Did you notice that here in Developer's Blog you can see the Author avatar and Bio right after the post?

Jexweber asked me on Twitter How did you do that?.

Well this is not a plugin it's just a few lines of code.

1. Open you single.php file of your theme.

2. Now place the functions (below) inside the Loop.

Look for the post content and put it after it. Then you will be sure is inside the Loop:

<?php the_content(); ?>Code language: HTML, XML (xml)

3. Add the functions

Get the Author avatar:

<?php echo get_avatar(get_the_author_id(), 60); ?>Code language: HTML, XML (xml)

Get the Author posts link:

<?php the_author_posts_link(); ?>Code language: HTML, XML (xml)

Get the Author Bio:

<?php the_author_meta('description'); ?>Code language: HTML, XML (xml)

(please notice the field description must be filled in the author profile page)

What else?

You can style the output with tables, divs and CSS.

Enjoy it πŸ˜‰

Comments

  1. For multi-author sites this is a very helpful tip, but it is also a great help for SEO, where you can share the PR between your sites.

Leave a Reply

Your email address will not be published. Required fields are marked *