简体   繁体   中英

How to add Author image and description - Wordpress

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; $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' ); ?> <?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); `

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM