2014-02-11 95 views
0

我一直在试图解决这些错误谷歌代码段测试。我一直在寻找single.php文件,但似乎无法纠正它。错误:至少必须为HatomEntry设置一个字段

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 &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> <?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('&laquo; %link (Previous Post)'); ?></div> 
      <div class="floatright"><?php next_post_link('(Next Post) %link &raquo;'); ?></div><br /> 
      <div class="floatleft"><?php previous_image_link(false, '&laquo; Previous Image'); ?></div> 
      <div class="floatright"><?php next_image_link(false, 'Next Image &raquo;'); ?></div> 
      </div></div> 

      <?php endwhile;?> 

      <!-- End the Loop. -->   

      <?php comments_template('', true); ?> 

</div>   
<?php get_sidebar(); ?> 
<?php get_footer(); ?> 

回答

0

谷歌正在寻找基于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> 

确保使用 'YMD' 为datetime属性,因为这是要求的标准格式那里。

的hCard作者字段需要多一点的标记,但覆盖几乎完全是在这里:

http://microformats.org/get-started/

0

你不一定需要修改的single.php文件。你可以使用像“schema-creator”这样的插件在你的文章/页面中包含丰富的代码片段,并且解决google web master中的hatom错误,你需要将这段代码添加到主题目录中的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字段,第二个函数将在您的文章末尾添加一个简短的句子,其中包含更新时间,帖子标题和作者以及所需的微数据。

相关问题