当前位置:首页 > 代码学苑 > 网建教程

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

来源:wordpress 作者: 2020-06-02

最近在使用Google丰富网页摘要测试工具的时候,发现对于默认wordpress博客,总会有三条错误信息出现,今天我就介绍一下,如何通过修改wordpress模版文件来修复这些错误信息的方法。

错误信息内容分别是:

Warning: Missing required field “entry-title”。

Warning: Missing required field “updated”。

Warning: Missing required hCard “author”。

修复<a href=http://m.iyoucaihua.com/e/search/result/?searchid=135 target=_blank class=infotextkey>wordpress</a>的Google丰富网页摘要错误

对于entry-title的错误信息修改方法是:

打开single.php文件,找到类似<h1><?php the_title(); ?></h1>一行,将其修改为<h1 class="entry-title title"><?php the_title(); ?></h1>(有些模版可能是h2或其他)

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

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

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

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

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

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

1
2
3
4
5
6
7
8
9
10
11
<?php
$separator '

猜你喜欢
    无相关信息