By Debbie Campbell
Expert Author
Article Date: 2010-09-07
There are a number of plugins and tutorials for adding a gravatar image to the meta info for WordPress posts. But my client wanted the ability for each other to upload/maintain their own images within their WordPress profiles.
Here's how I did it.First I installed the plugin Author Image - this places a simple upload box at the bottom of a user's profile page. Nice and simple.
Next, I used the code snippet provided for the plugin and added it to the .entry-meta section beside the author link in my template page:
1 | <?php the_author_image(); ?> |
I styled it to make it smaller, but again this was an easy task. Next, I wanted to make the image link to the author's posts page - that proved to be harder than expected, but eventually I got it working thanks to a post I found about an outdated user image plugin:
2 | $author_id=$post->post_author; |
3 | $curuser = get_userdata($author_id); |
4 | $author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename); |
5 | echo '<a title="' . sprintf( __( " href="%27%20.%20$author_post_url%20.%20%27">user_nicename ) . '" ' . '>'; |
Easy to implement and my client's authors can control their image from within their profile rather than having to update a gravatar.
Comments