找到你网站名为functions.php的文件,然后添加以下代码:

add_filter('get_avatar', 'qq_img', 10, 2);
function qq_img($avatar,$id_or_email)
{
$email = '';
//获取邮箱
if (is_numeric($id_or_email)){
$id = (int)$id_or_email;
$user = get_userdata($id);
if ($user)
$email = $user->user_email;
}else if(is_object($id_or_email)){
if (!empty($id_or_email->user_id)){
$id = (int)$id_or_email->user_id;
$user = get_userdata($id);
if ($user)
$email = $user->user_email;
}else if(!empty($id_or_email->comment_author_email)){
$email = $id_or_email->comment_author_email;
}
}else{
$email = $id_or_email;
}
$hash = md5(strtolower(trim($email)));
$url = 'https://avatar.zrahh.com/avatar/' . $hash;
if(stripos($email,"@qq.com"))//判断是否为QQ邮箱
{
$qq=str_ireplace("@qq.com","",$email);
if(preg_match("/^\d+$/",$qq))//正则过滤英文邮箱
{
$qqavatar="https://q2.qlogo.cn/headimg_dl?dst_uin=".$qq."&spec=100";
return '<img src="'.$qqavatar.'"class="avatar avatar-50 photo" width="50" height="50" alt="avatar" />';
}else{ //如果是英文QQ邮箱就调用Gravatar头像
return '<img src="'.$url.'"class="avatar avatar-50 photo" width="50" height="50" alt="avatar" />';
}
}else{ //不是QQ邮箱
return '<img src="'.$url.'"class="avatar avatar-50 photo" width="50" height="50" alt="avatar" />';
}
}