How to add Author image and description - Wordpress

3.4k views Asked by At

I am new to php.

I use author image widget. http://www.semiologic.com/software/author-image/

I use the following simple code to get the author image.

author.php: $auth_foto = the_author_image($authorid); echo $auth_foto;

it's working fine. its showing the author image.

Now I want to show the author description and his posts title below the image? How can I do that?

I've tried <?php the_author_meta( 'description' ); ?> but it's not working.

Thanks in advance.

SOLUTION it's working fine now when I using the following code.

`
$author_id=$post->post_author;

$auth_foto = the_author_image($author_id);

function auth_desc ($author_id) { 
echo the_author_meta('display_name', $author_id).'<br/>'; 
echo get_the_author_meta('user_email', $author_id).'<br/>';                 
echo the_author_meta( 'description', $author_id).'<br/>'.'<br/>'.'<br/>'; 
}  

echo $auth_foto; auth_desc($author_id); `
2

There are 2 answers

7
Mahmood Rehman On BEST ANSWER

this tag work with ID like :

<?php the_author_meta( $field, $userID ); ?> 

Details here

according to your code you can try like this :

<?php $auth_foto = the_author_image($authorid);
$userId = 1;
function auth_desc ($userId) { 
    echo get_the_author_meta('user_email', $userId); 
    echo the_author_meta('display_name', $userId);
 echo the_author_meta( 'description', $userId); } 
 echo $auth_foto; auth_desc($userId); ?>

In the above code assign dynamic value to $userID.

3
Gerald Schneider On

If you use the function outside of The Loop you need to add the author id.

<?php the_author_meta( 'description', $authorid ); ?>

Side note: some themes (especially the default themes) automatically show author name, picture and description when the blog has more than one user.