修改WordPress默认管理员头像的方法


打开当前主题functions.php函数模板,添加以下代码:

//修改默认头像
function mytheme_get_avatar( $avatar ) {
 $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="头像图片地址" class="avatar avatar-$2" height="$2" width="$2">',$avatar);
   return $avatar;
}
add_filter( 'get_avatar', 'mytheme_get_avatar' );

或者

//修改默认头像
function get_ssl_avatar($avatar) {
   $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://secure.gravatar.com/avatar/$1?s=$2" class="avatar avatar-$2" height="$2" width="$2">',$avatar);
   return $avatar;
}
add_filter('get_avatar', 'get_ssl_avatar');

标签:

文章发布时间:2021-01-08