1月
23
2014
wordpressでグーグルウェブマスターツール構造化データでのエラーの改善方法
wordpressでグーグルウェブマスターツールの構造化データでのエラーhentryの改善方法
ある日突然(多分12月頃から)ウェブマスターツールの構造化データでのエラーが多発する様になりました。ORZ..
何か、様子見で放って置いたんですが、何時の間にか1900件もエラーが!
- Warning: Missing required field “entry-title”.
- Warning: Missing required field “updated”.
- Warning: Missing required hCard “author”.
えーっと、真っ赤か。さすがにやーばーいーと思ったので、改善→ハマる。いつものパターン。
wordpressはmicro formatsを採用している様で、このエラーが出るらしいです。
解決策1:(ブログ形式でwordpressを使っている際(既にタイトル、日時、post by 名前(著者)が入ってる時)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<-- Fixing Warning: Missing required field “entry-title”--> | |
<h1 class="entry-title"><?php the_title(); ?></h1> | |
<-- Fixing Warning: Missing required field “updated” --> | |
<span class="date updated"><?php the_time(); ?></span> | |
<-- Fixing Warning: Missing required hCard “author” --> | |
<span class="vcard author"> | |
<span class="fn"><?php the_author(); ?></span> | |
</span> |
エラーを改善するには 1:post_class()からhentryを抜く。functionに記載バージョン
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_hentry( $classes ) { | |
$classes = array_diff($classes, array('hentry')); | |
return $classes; | |
} | |
add_filter('post_class', 'remove_hentry'); |
2:テンプレートからpost_class()を書き換える。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
//上記を変更 | |
<div id="post"> |
と言う事で 2を採用して、何とかエラーが全部無くなった!(1日以上考えた)
参考サイト
:ウェブマスターツールの構造化データ(hentry)のエラー対策
:WordPressユーザー要注意!〜構造化データのエラーでアクセス激減
:How to Fix – hfeed Warning: At least one field must be set for HatomEntry
Maybe you like!!
- << PREVIOUS:曾根崎心中/角田光代 |ボルダリング道場3:NEXT>>
Comment
【コメントの投稿について】
Furaha clothingでは、「Disqus」のコメントを使っています。
ツイッターやフェイスブックなどにアカウントをお持ちの方は、ログインすることで
自分のプロフィールでコメント出来ます。アカウントの無い方もメールアドレスでコメント出来ます。
(入力したアドレスはコメントには表示されません。)