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?

4 Answers
4

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:

<?php echo get_avatar( get_the_author_meta( 'ID' ) , 32 ); ?>

Where ’32’ is the size of the image. If it’s outside the loop, then just specify the author’s user ID.

Tags:

Leave a Reply

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