有个需求,想根据email决定输出的头像,如何处理呢?代码如下:

add_filter('get_avatar', 'author_avatar', 1, 5);
function author_avatar($avatar, $id_or_email, $size, $default, $alt) {
if ($id_or_email=="abc@123.com") {
return "<img src='https://static.shipengliang.com/wp-content/uploads/2019/12/icebox.jpg' class='sp-no-webp' height='150' width='150' srcset='https://static.shipengliang.com/wp-content/uploads/2019/12/icebox.jpg'>";
} else {
return $avatar;
}
}


与《WordPress hook get_avatar 方法》相关的博文:

留言