Search Console 構造化データ エラー対策

Raspberry Pi + nginx = WordPress
WordPress のテーマ Twenty Sixteen での、
Search Console 構造化データエラー
への対処結果。
 
Search Console での構造化データエラーが2種類発生するようになった。
 
①.hentry(マークアップ: microformats.org)エラー
author がありません
updated がありません
②.Person(マークアップ: schema.org)エラー
homeLocation がありません
 
 

 

スポンサー リンク

 

 
 
1. 構造化データエラー発生状況
 
hentryエラー:27件、Personエラー:1件、合計:28件。
henry103
 
hentryエラーの内容は、
・author がありません
・updated がありません
henry112
 
 
2. author / updated がありません対策
 
hentry(マークアップ: microformats.org)エラー対策
 
 
対処:その-1
外観→テーマの編集で、
① template-tags.php ← 
2016.10.16修正
 ② content-page.php ← 2016.10.16修正
の2つのphpファイルを編集する。
 
①.template-tags.php の修正は、下記位置に "updated" を追記した。
template-tags2
 
実際ソースのコード。
function twentysixteen_entry_date() {
	$time_string = '<time class="<span style="color: #3366ff;">entry-date published updated</span>" datetime="%1$s">%2$s</time>';

	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$time_string = '<time class="entry-date published <span style="color: #ff0000;">updated</span>" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
	}
 
②.content-page.php の修正は、下記位置に、次のステートメント を追記した。
content-page2
 
追記したソースコード。
<time class="entry-date <span style="color: #ff0000;">updated</span>" style="display:none" datetime="<?php echo esc_attr( get_the_date( 'c' ) ) ?>"><?php echo esc_html( get_the_date() ) ?></time>
 
<span class="byline"><span class="<span style="color: #ff0000;">author vcard</span>"><a class="url fn n" href="esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) )" rel="author"><?php echo get_the_author(); ?></a></span></span>
 
以上の処置を施してしばらく待つと、構造化データに関するエラーが、合計:17件と、hentryのエラーが11件減り16件になった。
henry104
 
 
対処:その-2
外観→テーマの編集で、
 content-single.php
 ← 2016.10.20 修正
のphpファイルを編集する。
 
③.さらに、content-single.php にも content-page.php と同じ修正を施す。下記位置に、同じステートメント を追記する。
content-single03
 
また、しばらく待つと、構造化データに関するエラーが、合計:13件と、hentryのエラーが4件減り12件になった。
henry105
 
この修正を施した結果、記事下に『ユーザー名』が表示されるようになった。
content-php122
 
更に、このリンクをクリックするとエラーになる。
追記:この表示を消すために、auther に display:none をいれる。
<span class="byline" style="display:none">
content-php132記事横にも表示されるが、このリンクは正しく動作する。
 
ユーザー名の表示を変更するために、ダッシュボードの 『ユーザー』→『あなたのプロフィール』で『ブログ上の表示名』を設定。
content-php142
 
すると、表示名が変わった。
content-php152
 
記事横の表示も、同じく変更された。
content-php162
 
ついでに、『プロフィール情報』に説明文を入れ、『プロフィール写真』の下にある『Gravatar 』をクリックしてみる。
content-php172
 
Gravatar サイトが表示される。
content-php182
 
WordPress.com のアカウントでログインし、プロフィール写真を設定する。
content-php192
 
すると、写真付きで『投稿者』が表示されるようになった。
content-php212
 
この『投稿者』の表示が必要かどうか、・・・ウィジェットのプロフィール欄と重複することになった。(『プロフィール情報』を削除(空欄に)すれば、表示されなくなる。)
 
対処:その-3
外観→テーマの編集で、
 content.php
 ← 2016.10.24 修正
のphpファイルを編集する。
 
外観→テーマの編集で、content.php の下記位置にコードを追記する。
content-php112
 

このcontent.phpに追加するコードの auther にも display:none を追加した。

<time class="entry-date <span style="color: #ff0000;">updated</span>" style="<span style="color: #ff0000;">display:none</span>" datetime="<?php echo esc_attr( get_the_date( 'c' ) ) ?>"><?php echo esc_html( get_the_date() ) ?></time>
 
<span class="byline" style="<span style="color: #ff0000;">display:none</span>" ><span class="<span style="color: #ff0000;">author vcard</span>"><a class="url fn n" href="esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) )" rel="author"><?php echo get_the_author(); ?></a></span></span>
 
これで、エラーが 3件 減少。
 
 
対処:その-4
外観→テーマの編集で、
 template-tags.php
 ← 2016.10.31
のphpファイルに updated がありません の追加修正をする。

 
template-tags.php の下記行を修正。
template-tags512
 
修正前。
function twentysixteen_entry_date() {
	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';

	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
	}
修正後。time class= を追記。
function twentysixteen_entry_date() {
	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time><span style="color: #ff0000;"><time class="updated" datetime="%3$s">%4$s</time>'</span>;

	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
	}
 
 
対処:その-5
外観→テーマの編集で、
 footer.php
 ← 2016.11.01 修正
のphpファイルを編集する。
 
footer.php の下記位置にステートメントを追加する。
footer-php114
 
追加ステートメント。Google+ プロフィールのURLを入れて追加する。
<span class=”vcard author”><span class=”fn”>by <a href=”<span style="color: #ff0000;">https://plus.google.com/u/0/123456789012345678901/posts</span>” rel=”author”>tacsan</a></span></span>
 
 
対処:その-6
プラグインの、
 All in One SEO
 ← 2016.11.02 修正
の設定を変更する。
 
Googleの検索結果に著者情報を表示させる設定を行う。
All in One SEO の一般設定にある、Google 設定で Google+ ディフォルトプロフィールに、Google+ プロフィールのURLを登録する。
googlid056
 
これにより、自分のサイトからGoogle+へのリンクを貼り、サイトの著者が自分であると言うことをGoogleに知らせる。
 
Google+ プロフィールのURL取得要領。
 
右上のアカウント写真をクリックし、Google+ プロフィールを選択する。
googlid012
 
すると、URL欄に『Google+ プロフィールのURL』が表示される。
googlid022
 
これをコピーして保存しておく。
 
~ 対策まとめ ~  
①.template-tags.php ← 2016.10.16 & 10.31 追加修正
②.content-page.php ← 2016.10.16 修正
③.content-single.php ← 2016.10.20 修正
④.content.php ← 2016.10.24 修正
⑤.
footer.php ← 2016.11.01 修正
⑥.プラグイン
All in One SEO
の設定を変更する。← 2016.11.02 修正
 
修正結果が反映されるには時間差がある。
エラー発生状況の推移(2016.11.06 現在)。
kouzoukaerr014
 
まだ、
・画像ファイルが1件・・・author がありません
・固定ページが2件・・・author がありません と updated がありません
の、計3件が残っている。
追記:2016.11.14 hentryエラーがゼロになった。
 
 
追記:失敗事例
 
外観→テーマの編集で、
 template-tags.php
 ← 2016.11.01
のphpファイルに
Google+のアカウントID を組み込んでみた。
 
組み込んだ位置。
template-tags532
 
組み込んだステートメント。
?>

<span class=”vcard author”><span class=”fn”>by <a href=”https://plus.google.com/u/0/123456789012345678901/postsrel=”author”>123456789012345678901
</a></span></span>
 
ダッシュボードのログイン画面に、Google+のアカウントID 表示されるようになる。
googlid032
 
修正後、メディアアップロードが出来なくなり、元に戻す。
googlid042
 
 
3. homeLocation がありません対策
 
Person(マークアップ: schema.org)エラー対策
 
構造化データのデータタイプ Person でエラーが発生。
person112
 
エラーの内容は『homeLocation がありません』。
person132
 
ページーの詳細を見みてみると、” sameAs: ” に『 FacebookのプロフィールURL 』が表示されている。
person142
 
そこで、『 FacebookのプロフィールURL 』を表示し、基本データの『住所』を登録してみる。
person212
 
2016.11.08 只今、テスト中。(どう対処すべきか判らない。)
2017.01.14 理由は不明だが、このエラーが突如消えた。
 

以上。
(2016.11.06)

 

 

スポンサー リンク

 

             

 

 

 

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

This site uses Akismet to reduce spam. Learn how your comment data is processed.