如何解决Google Search Console提示的错误类型Missing:fn?

一. 生搬硬套

Google Search Console提示结构化数据错误,如下图。
结构化数据提示错误

一直苦于找不到解决方法,这个问题就被搁置了。今天再次查看Google Search Console,这个Missing:fn错误提示特别碍眼,不得不想办法尽快解决掉。在Google中查找了很多方法,按部就班地把所有方法都试了一遍,最终还是失败了。哎,罢了,不能放弃ing,只能自己死磕想办法解决了。文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

二. 溯本求源

点开Misssing:fn进一步查找原因,如下图:文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

missing:fn错误的具体原因文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

在photo那一项出现Gravatar,我的博客确实有开启Gravatar图像,难道是gravatar的原因?这个gravatar图像只会出现在评论里。从Google Search Console结构化数据错误提示的两个页面:/leave-a-message和/building/mail-alerts.html,都有评论,且评论中的图像都是调用Gravatar,所以才出现了错误?文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

三. 举一反三

曾在themegrill论坛有这样的一个帖子,和我的问题很相似:文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

missing:fn提问文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

其中有一个不错的回复,如下:文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

missing:fn问题回复文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

comment-author-link?评论者的链接?看来提问人是因为评论者的链接出现了missing:fn错误。解决方法是到inc/functions.php中在一行代码中加入fn类,问题就能解决。而我的问题是gravatar图像,是不是给gravatar图像增加fn类,问题就能解决?文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

找到htdocs/wp-content/thems/你使用的主题/inc/inc.php或者是functions.php,查找gravatar图像的代码:文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

// gravatar头像调用
function cn_avatar($avatar) {
	$avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://cn.gravatar.com/avatar/$1?s=$2&d=mm" alt="avatar" class="avatar avatar-$2" height="$2" width="$2">',$avatar);
	return $avatar;
}

function ssl_avatar($avatar) {
	$avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://secure.gravatar.com/avatar/$1?s=$2&d=mm" alt="avatar" class="avatar avatar-$2" height="$2" width="$2">',$avatar);
	return $avatar;
}

在2个class中增加fn类,记得与前面的一个类之间要空一格。文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

// gravatar头像调用
function cn_avatar($avatar) {
	$avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://cn.gravatar.com/avatar/$1?s=$2&d=mm" alt="avatar" class="avatar avatar-$2 fn" height="$2" width="$2">',$avatar);
	return $avatar;
}

function ssl_avatar($avatar) {
	$avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://secure.gravatar.com/avatar/$1?s=$2&d=mm" alt="avatar" class="avatar avatar-$2 fn" height="$2" width="$2">',$avatar);
	return $avatar;
}

四. 验证

通过结构化测试工具验证文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

结构化数据测试工具验证1文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

结构化数据测试工具验证2文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

问题解决~~~文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

 文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

 文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html 文章源自MAY的SEO博客-https://may90.com/seo/google/missingfn.html

  • 我的微信
  • 扫一扫微信,添加好友
  • weinxin
  • 我的微信公众号
  • 关注公众号,了解最新动态
  • weinxin
  • 本文由 发表于 2019年1月12日
  • 转载请务必保留本文链接:https://may90.com/seo/google/missingfn.html
评论  2  访客  1  作者  1
    • boke112导航 6

      看到最后才发现这个问题竟然这么简单就解决了,学习了。

        • MAY的SEO博客

          @ boke112导航 谢谢您的评论。刚申请了贵站的收录,希望能通过 :oops:

      发表评论

      匿名网友 填写信息

      :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

      确定