我的代碼這樣做,列出哪個作者發佈在當前類別。但get_avatar
功能不正確的工作。我使用簡單的本地頭像插件。這是工作author.php沒有任何問題。但是當我使用它在我的這個代碼,它是上市相同的,錯誤的作者照片(我最近筆者圖片You can look this picture)Wordpress的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 }?>
可以,我的朋友,多張貼不鼓勵,請選擇一個網站,並堅持下去,檢查:http://meta.stackexchange.com/q/64068 – brasofilo