2014-02-11 92 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字段,第二個函數將在您的文章末尾添加一個簡短的句子,其中包含更新時間,帖子標題和作者以及所需的微數據。

相關問題