建復WordPress的Google豐碩網頁擇要毛病

比來正在應用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=/.get_category_link($category->term_id)./ itemprop=/url/><span itemprop=/title/>$category->name</span></a>
;
echo '</div>';
}}
?>