[英]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.