我几乎可以肯定我不是第一个有这个问题的人,但是当我在Google Snippet test Tool上测试我的(WordPress) page时,我得到了很多错误,比如:
hatom-feed
hatom-entry:
Fout: At least one field must be set for HatomEntry.
Fout: Missing required field "entry-title".
Fout: Missing required field "updated".
Fout: Missing required hCard "author".我找到了一些关于这方面的tutorials,但那是针对标准WordPress主题的。我使用的是来自ThemeForest的Inovado,但我不知道必须在哪个文件中编辑此数据。
熟悉这个的人吗?
我在代码片段审查方面也遇到了问题...测试结果很好,但不会出现在de Google搜索结果中。不知道为什么..。
发布于 2014-08-22 15:53:03
您可以将此代码添加到主题目录中的function.php文件中,它将解决这些问题。
//mod content
function hatom_mod_post_content ($content) {
if ( in_the_loop() && !is_page() ) {
$content = '<span class="entry-content">'.$content.'</span>';
}
return $content;
}
add_filter( 'the_content', 'hatom_mod_post_content');
//add hatom data
function add_mod_hatom_data($content) {
$t = get_the_modified_time('F jS, Y');
$author = get_the_author();
$title = get_the_title();
if(is_single()) {
$content .= '<div class="hatom-extra"><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_mod_hatom_data');代码包含2个函数。第一个函数将使用“the_content”的WordPress过滤器钩子将“entry-content”类添加到文章中。为了添加其他基本的hAtom字段,第二个函数将在文章末尾添加一小句话,其中包含更新时间、帖子标题和作者,以及所需的微数据。
https://stackoverflow.com/questions/19316102
复制相似问题