原来Wordpress版本头像不显示,都是修改wp-includes文件夹下的pluggable.php(之前的文章:http://uu126.cn/post/1554.html),后来升级到4.2后,发现这个方法不行了,根本就找不到要更改的地,没办法又不想用插件,只好请教度娘,终于让我找到方法并解决了,下面就转述一下哈:
升级wordpress 之后去按照以前的方法找服务器设置,发现找不到了。蛋疼啊,但是最近又有点忙,所以一直没管它,今天搜索了一下发现新的头像服务器函数已经移动到”WordPress4.2.1wp-includeslink-template.php”(3604,29): $url = sprintf( ‘http://%d.gravatar.com/avatar/%s’, $gravatar_server, $email_hash );这里来了,如下:
if ( $email_hash ) { $args[‘found_avatar’] = true; $gravatar_server = hexdec( $email_hash[0] ) % 3; } else { $gravatar_server = rand( 0, 2 ); } $url_args = array( ‘s’ => $args[‘size’], ‘d’ => $args[‘default‘], ‘f’ => $args[‘force_default’] ? ‘y’ : false, ‘r’ => $args[‘rating’], ); $url = sprintf( ‘http://%d.gravatar.com/avatar/%s’, $gravatar_server, $email_hash ); $url = add_query_arg( rawurlencode_deep( array_filter( $url_args ) ), set_url_scheme( $url, $args[‘scheme’] ) );
修改也很简单,将上面的3604行修改为:
$url = sprintf( ‘http://cn.gravatar.com/avatar/%s’, $email_hash );
保存好上存覆盖,再刷新网页看看,是不是看见那小头像了,赶紧行动吧!