これを行う私のコードは、現在のカテゴリに投稿した著者をリストします。しかし、get_avatar
機能が正しく動作していません。シンプルなローカル アバター プラグインを使用しています。author.php は問題なく動作しています。しかし、このコードを使用すると、同じ著者の写真と間違った著者の写真がリストされます(私の最新の著者の写真。この写真を見ることができます)
私のコード:
<?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 }?>