修复Wordpress的Google丰富网页摘要错误

王朝互联网·作者佚名  2012-10-20
窄屏简体版  字體: |||超大  

最近在使用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 class="title entry-title"><?php the_title(); ?></h1>(有些模版可能是h2或其他)

对于updated的错误信息修改方法是:

打开single.php文件,找到<?php the_date();?>一行,将其修改为<div class="date updated"><?php the_time('F S, Y'); ?></div>

对于author的错误信息修改方法是:

打开single.php文件,找到<?php the_author(); ?>一行,将其修改为<span class="vcard author"><span class="fn"><?php the_author(); ?></span></span>

另外,在昨天写的“Google丰富网页摘要教程”中,有些读者希望能举个Wordpress模版修改的例子,下面就是一个Wordpress模版的例子。

打开single.php文件,在适当位置添加如下代码:

<?php

$separator = '&rsaquo;';

$category = get_the_category();

if ($category) {

foreach($category as $category) {

echo '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display:inline">';

echo $separator . "<a href=\"".get_category_link($category->term_id)."\" itemprop=\"url\"><span itemprop=\"title\">$category->name</span></a>

";

echo '</div>';

}}

?>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航