我一直在尝试在Google代码段测试中修复这些错误。我一直在查看single.php文件,但似乎无法纠正它。
hatom-entry:
Error: At least one field must be set for HatomEntry.
Error: Missing required field "entry-title".
Error: Missing required field "updated".
Error: Missing required hCard "author".
Error: At least one field must be set for HatomEntry.
Error: Missing required field "entry-title".
Error: Missing required field "updated".
Error: Missing required hCard "author".
这是我的single.php代码:
<?php
/* Small Business Theme's Single Page to display Single Page or Post
Copyright: 2012-2013, D5 Creation, www.d5creation.com
Based on the Simplest D5 Framework for WordPress
Since Small Business 1.0
*/
get_header(); ?>
<div id="content">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <h3 class="subtitle"><?php echo get_post_meta($post->ID, 'sb_subtitle', 'true'); ?></h3>
<h1 class="page-title"><?php the_title(); ?></h1>
<p class="postmetadataw">Posted by: <?php the_author_posts_link(); ?> | on <span class="post_date"><?php the_time('F j, Y'); ?></p>
<div class="content-ver-sep"> </div>
<div class="entrytext"><?php the_post_thumbnail('category-thumb'); ?>
<?php the_content(); ?>
<div class="clear"> </div>
<div class="up-bottom-border">
<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php the_tags('<br />Tags: ', ', ', '<br />'); ?></p>
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . 'Pages:' . '</span>', 'after' => '</div>' ) ); ?>
<div class="content-ver-sep"> </div>
<div class="floatleft"><?php previous_post_link('« %link (Previous Post)'); ?></div>
<div class="floatright"><?php next_post_link('(Next Post) %link »'); ?></div><br />
<div class="floatleft"><?php previous_image_link( false, '« Previous Image' ); ?></div>
<div class="floatright"><?php next_image_link( false, 'Next Image »' ); ?></div>
</div></div>
<?php endwhile;?>
<!-- End the Loop. -->
<?php comments_template( '', true ); ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
答案 0 :(得分:0)
Google正在根据hAtom微格式标准寻找有关这些元素的特定类:
http://microformats.org/wiki/hatom/
在您的情况下,您想要更改:
<h1 class="page-title">
为:
<h1 class="page-title entry-title">
并改变:
<span class="post_date"><?php the_time('F j, Y'); ?>
为:
<time datetime="<?php the_time( 'Y-m-d' ) ?>" class="updated"><?php the_time('F j, Y'); ?></time>
确保使用'Y-m-d'作为datetime属性,因为这是此处所需的标准格式。
hCard作者字段需要更多标记,但在此完全涵盖:
答案 1 :(得分:0)
您不一定需要修改single.php文件。你可以使用&#34; schema-creator&#34;等插件。要在您的帖子/页面中包含丰富的代码段并解决Google网站管理员中的错误,您需要将这段代码添加到主题目录中的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个功能。第一个函数将使用WordPress过滤器钩子为“the_content”添加“entry-content”类到文章。要添加其他必要的hAtom字段,第二个函数将在帖子文章的末尾添加一个简短的句子,其中包含更新的时间,帖子标题和作者,以及所需的微数据。