2013-01-14 25 views
0

我的代碼這樣做,列出哪個作者發佈在當前類別。但get_avatar功能不正確的工作。我使用簡單的本地頭像插件。這是工作author.php沒有任何問題。但是當我使用它在我的這個代碼,它是上市相同的,錯誤的作者照片(我最近筆者圖片You can look this pictureWordpress的get_avatar功能不正確的工作

我的代碼:

<?php if (is_category()) {?> 
<?php 
$current_category = single_cat_title(「」, false); 
$author_array = array(); 
$args = array(
'numberposts' => -1, 
'category_name' => $current_category, 
'orderby' => 'author', 
'order' => 'ASC' 
); 
$cat_posts = get_posts($args); 
foreach ($cat_posts as $cat_post) : 
if (!in_array($cat_post->post_author,$author_array)) { 
$author_array[] = $cat_post->post_author; 
} 
endforeach; 
foreach ($author_array as $author) : 
$auth = get_userdata($author)->display_name; 
$autid= get_userdata($author)->ID; 
echo get_avatar(get_the_author_email(), '32'); 
echo "<a href='?author="; 
echo $autid; 
echo "'>"; 
echo $auth; 
echo "</a>"; 
echo "<br />"; 
endforeach; 
?> 
<?php }?> 
+0

可以,我的朋友,多張貼不鼓勵,請選擇一個網站,並堅持下去,檢查:http://meta.stackexchange.com/q/64068 – brasofilo

回答

0

改變這個echo get_avatar(get_the_author_email(), '32');echo get_avatar($autid, '32');

get_the_author_email()回報作者在wordpress的當前loop的電子郵件,而不是從您的foreach循環。

+1

這是完美的工作。謝謝@Reigel – Genxer