1

我是 php 新手。

我使用作者图像小部件。 http://www.semiologic.com/software/author-image/

我使用以下简单代码来获取作者图像。

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

它工作正常。它显示了作者的形象。

现在我想在图片下方显示作者描述和他的帖子标题?我怎样才能做到这一点?

我试过<?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); `
4

2 回答 2

2

此标签与 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.

于 2013-12-09T09:26:10.423 回答
1

如果您在 The Loop 之外使用该功能,则需要添加作者 ID。

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

旁注:当博客拥有多个用户时,某些主题(尤其是默认主题)会自动显示作者姓名、图片和描述。

于 2013-12-09T09:23:32.477 回答