I need to display author image along with posts. I used the following code to display posts with author image.
$the_query = new WP_Query("post_type=post&paged=".get_query_var('paged'));
while ( $the_query->have_posts() ) : $the_query->the_post();
<?php the_excerpt(); ?>
<p><?php the_author_image(); ?></p>
<?php endwhile; ?>
But the author image didn’t display. I couldn’t track the error. How can i do this?
I know this is old, but I just came across it shortly before I came across the solution.
To display the author image inside the loop, just use this code:
Where ’32’ is the size of the image. If it’s outside the loop, then just specify the author’s user ID.
If you are not using it inside a normal loop, get the author ID a different way and use the function like this:
Basically you need to supply the author ID to the function if it is not in a proper loop. If you are having trouble getting the ID from your query let me know.
Note the answers here are for the built-in Gravatar photo. If you want to choose/set photos for your authors you’ll need a plugin or write your own as miahelf mentions.
Upload a specific image for author requires 2 things:
Please Note that get_the_author_image() is deprecated and will not work for WP > 3.0