化身功能有一个过滤器挂钩get_avatar
. 您应该使用它来过滤并替换为您的函数,就像下面的示例一样,没有逻辑。
add_filter( \'get_avatar\', \'get_avatar\', 10, 5 );
/**
* Override get_avatar with uploaded avatar else default.
*/
function get_avatar( $avatar, $id_or_email, $size, $default, $alt )
{
$avatar = "<img alt=\'{$alt}\' src=\'{$avatar_path}\' class=\'avatar avatar-{$size} photo avatar-default\' height=\'{$size}\' width=\'{$size}\' />";
return $avatar;
}