如果您有项目需要开发,可以联系我们
果果开发

修改WordPress默认头像

作者: admin 发布时间:2024-11-15 16:00:32

WordPress默认头像由于无法访问,总是一个404,可以使用下面的代码来修改。

add_filter('get_avatar', 'my_custom_avatar', 1, 5);

function my_custom_avatar($avatar, $id_or_email, $size, $default, $alt)
{
    return '<img alt="' . esc_attr($alt) . '" src="https://auth.ggdoc.cn/static/image/avatar.jpg" class="avatar avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
}

上面将所有用户的头像链接修改为了 https://auth.ggdoc.cn/static/image/avatar.jpg