If you want to get the Author information such as name, profile image and name from post ID then it can be retrieved in the following way.
To display the author name use the following code.
<?php $author_id=$post->post_author; ?>
Now suppose you want to get the Author Avatar. The avatar is fetched in the following way.
<img src="<?php echo the_author_meta( 'avatar' , $author_id ); ?> " width="140" height="140" class="avatar" alt="<?php echo the_author_meta( 'display_name' , $author_id ); ?>" />
This will display the author avatar.To display the author name use the following code.
<?php echo the_author_meta( 'user_nicename' , $author_id ); ?>
This will display the author name.
No comments:
Post a Comment