修复WordPress在Google站长工具的hatom错误

本来今日杂记使用的主题是有那些hatom标签的,但是不知道什么原因Google站长工具没有识别出来,百度了一下关于hatom的信息,没有出来几个有用的,更别说在百度里找解决这个错误的答案了,遂Google之,得几篇英文博客的答案,取方法最简单的一篇记录于此,原文链接在此。先看看修复前Google站长工具里显示的错误。
hatom错误
看完错误案例,把下面的代码添加到主题的function.php文件里。

//add hatom data
function add_suf_hatom_data($content) {
$t = get_the_modified_time('F jS, Y');
$author = get_the_author();
$title = get_the_title();
if (is_home() || is_singular() || is_archive() ) {
$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
}
return $content;
}
add_filter('the_content', 'add_suf_hatom_data');

下面是添加这段代码后,同一文章在Google站长工具里的检测结果。
修复hatom错误后显示结果

我猜~这些文章你可能也感兴趣

Nie
Tags

相关文章

*


Top