The Entry Archive
How to Automatically Generate Author Photos for WordPress Blog Entries
One of the great things about WordPress is that it allows multiple users to contribute to a single blog. Say you’ve got a couple of friends who want to join in on the authoring of your website and WordPress possesses the capability to make that happen easily and effectively. Now say that you and your buds would not only like to author entries on the same blog but would also like to automatically output a standard author photo beside each of the entries as they are published. Well, then WordPress gets a little finicky.

The solution that I came up with involves creating a folder for author photos inside of the ‘wp-content’ directory and using the the_author_nickname() template tag within an IMG tag to automatically output photos whenever an author publishes an entry. The following is an example of the code that I use to make this happen:
<img width="[width]” height=”[height]”
src=”<?php bloginfo(’url’); ?>/wp-content
/author_photos/<?php the_author_nickname(); ?>.gif”
alt=”Written by <?php the_author() ?>”
title=”Written by <?php the_author() ?>”/>
(Where [width] and [height] are the dimensions of the author photos. These must be uniform widths and heights.)
The Setup
Using your favorite FTP client, create a folder inside of the ‘wp-content’ directory that is titled ‘author_photos’.

The ‘author_photos’ folder will contain every author photo that your blog requires. It is essential that the image format you use for each author photo remains consistent with the other images in the folder. You can name the photos whatever you like; a suggestion that I make is to name each author photo in a ‘lastname_firstname’ format so that individual photos are easy to locate when you need to update or delete a user from your editorial group.
Author Photo Name = Nickname
This is a very important step. In the WordPress “Profile and Personal Options” area there is a field that allows each user to type in a nickname. For each author, the name that will be entered into the “Nickname” field must be exactly the name of the author photo image, sans the file extension. Here is an example to give you an idea of what I am talking about:

In this example, we place an author photo inside of the ‘author_photos’ folder called ‘doe_jane.gif’ and we also enter in the phrase ‘doe_jane’ into the “Nickname” portion of the user profile. By syncing the “Nickname” field with the author photo filename, our WordPress template tag can properly retrieve the correct author photo for each post that is published in a multi-user blogging platform.

The Code
Once again, here is the code that achieves the effect we are going for:
<img width="[width]” height=”[height]”
src=”<?php bloginfo(’url’); ?>/wp-content
/author_photos/<?php the_author_nickname(); ?>.gif”
alt=”Written by <?php the_author() ?>”
title=”Written by <?php the_author() ?>”/>
Until the developers at WordPress come up with another way to manage multiple author photos, the above solution should work just fine. Because there are already predefined WordPress template tags for the first and last names of each user, the nickname field can become somewhat of a free for all to fit whatever additional needs that you may have when it comes to online publishing. Enjoy!
Post Date: March 6, 2007
7 Responses to “How to Automatically Generate Author Photos for WordPress Blog Entries”
Michael Pierce:
April 20th, 2007 at 12:51 pm
soo what I needed!
leasure@lovefineart.com:
January 4th, 2008 at 12:58 pm
Thanks! I’ll give this a try. I really love your blog and will be back repeatedly. Keep up the great work.
Net Covered:
April 11th, 2008 at 2:33 pm
Really helpful article thanks :) Will use this…
coroijo:
July 16th, 2008 at 3:36 am
why use nickname?
nickname can change.. login name not..
Search Marketing Courses:
August 18th, 2008 at 8:28 pm
Thanks - I’m working on a blog with multiple authors and I couldn’t find a plugin or any other advice to easily do this. Your article was exactly what I was looking for.
All the best,
Moshe
Mica:
September 10th, 2008 at 6:46 pm
Sorry if this is a dumb question, but which template do I add the code to?
Philip Arthur Moore:
September 10th, 2008 at 7:02 pm
Hi Mica,
You can add this to any page in your template. So, for example, if you’d like the photos to show up on the index page, then edit the index.php page. But, this code is pretty outdated and there are several options for WordPress author photo plugins on the WP website. You may want to check those out before diving into this code.
Cheers,
Philip
Leave a Reply