WordPress用户头像无法显现让我很抓狂,由于真实太难看了。真无法忍受,于是在此共享WordPress用户头像不显现的处理方法,期望能给有需求的人供给些许帮助。
那么,为何WordPress头像无法显现呢?其原因是WordPress默许运用Gravatar头像(Gravatar是Globally Recognized Avatar的缩写,是gravatar推出的一项服务,意为“全球通用头像”),而Gravatar在国内被墙致使在国内无法访问Gravatar头像服务,因此就呈现了WordPress头像的破图现象。
怎么处理WordPress用户头像不显现的疑问呢?
运用Gravatar头像服务的(HTTPS)加密线路
在主题目录中找到functions.php文件,翻开修正,在代码最终加上以下代码即可:
function fox_get_https_avatar($avatar) {
$avatar = str_replace(array("", "", "", ""), "", $avatar);
$avatar = str_replace("http://", "https://", $avatar);
return $avatar;
}
add_filter('get_avatar', 'fox_get_https_avatar');
修正pluggable.php 文件,更改头像调用
在/wp-includes中找到pluggable.php文件,找到以下代码:
if ( is_ssl() ) {
$host = '';
} else {
if ( !empty($email) )
$host = sprintf( "http://%", ( hexdec( $email_hash[0] ) % 2 ) );
else
$host = '';
}
然后将这段代码修正成:
if ( is_ssl() )
$host = ‘’;
else $host = ‘’;
保存,完结!