最近在使用 Google 豐富網頁摘要測試工具的時候,發現對於默認 WordPress 博客,總會有三條錯誤信息出現,今天我就介紹一下,如何通過修改 WordPress 模版文件來修復這些錯誤信息的方法。
錯誤信息內容分別是:
Warning: Missing required field 「entry-title」 。
Warning: Missing required field 「updated」 。
Warning: Missing required hCard 「author」 。

對於 entry-title 的錯誤信息修改方法是:
打開single.php文件,找到類似<h1><?php the_title(); ?></h1> 一行,將其修改為<h1 ><?php the_title(); ?></h1>(有些模版可能是 h2 或其他)

對於 updated 的錯誤信息修改方法是:
打開single.php文件,找到<?php the_date();?> 一行,將其修改為<div ><?php the_time('F S, Y'); ?></div>

對於 author 的錯誤信息修改方法是:
打開single.php文件,找到<?php the_author(); ?> 一行,將其修改為<span ><span ><?php the_author(); ?></span></span>