[英]How to add Author image and description - Wordpress
我是php的新手。
我使用作者图像小部件。 http://www.semiologic.com/software/author-image/
我使用以下简单代码来获取作者图像。
author.php: $auth_foto = the_author_image($authorid); echo $auth_foto;
$auth_foto = the_author_image($authorid); echo $auth_foto;
它工作正常。 它显示了作者的形象。
现在我想在图片下面显示作者描述和他的帖子标题? 我怎样才能做到这一点?
我试过<?php the_author_meta( 'description' ); ?>
<?php the_author_meta( 'description' ); ?>
但它不工作。
提前致谢。
解决方案 ,当我使用以下代码时,它正常工作。
`
$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); `
此标记使用ID,如:
<?php the_author_meta( $field, $userID ); ?>
细节在这里
根据您的代码,您可以尝试这样:
<?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); ?>
在上面的代码中,将动态值分配给$userID
。
如果您使用The Loop之外的函数,则需要添加作者ID。
<?php the_author_meta( 'description', $authorid ); ?>
附注:当博客有多个用户时,某些主题(尤其是默认主题)会自动显示作者姓名,图片和说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.