以上 2 years ago I published an article on how to fix problems with WordPress themes which didn’t pass the Google Rich Snippets Testing Tool. それ以来、多くが変更されました - ワードプレスとほとんどのテーマは、より良いサポートがある, HTML5とCSS3が到着しました, とGoogle, Yahoo and Bing got together and decided to focus on Microdata, schema.org経由. 一度マイクロフォーマットは、ページをマークアップするための最も簡単な方法のように見えた, およびテストツールは、これらのための最も包括的なサポートを持っていた. ミクロデータに移動し、WordPressへの変更は、新しい記事を必要と: これがそうだ!
代わりに、私はすべての情報を提供しようとすることを決定したさまざまなテーマごとに個別の記事の多くを持っていることの 1 ガイド. This makes it easier to keep up to date, だけが存在することを意味し 1 すべての要求と議論の中心点. It also makes more sense as several of the steps are the same regardless of what theme you are using. I’m not going to cover all the optional extras in this article, ただ基本的なツールを使用してサイトを検証するために取得する. あなたが見つける必要があることを管理したら、余分なマークアップを追加することは比較的容易である. そう始めることができます...
Add a link from your google profile to your site
あなたは上の表示されます 私のGoogle のプロファイル 私は公衆のリンクを持っている https://diymediahome.org - あなたがあなた自身のサイトのための同じをする必要があります. 理想的にはこれと同じ方法で、あなたのサイトにリンクされているGoogleプロフィールを持っている、あなたの著者のすべてが必要になります.
- にログインしてください Googleのプロファイル
- あなたが表示されるまでスクロール リンク どこかにページの右下に向けてのセクション
- をクリックします 編集 リンク
- 下 contributor to セクションをクリック お客トムリンクを追加
- テキストの右側のボックスを確認してください contributor to に設定されています 公共
- あなたのサイト名を入力してください (例えば. DIY メディアホーム) およびアドレス (例えば. https://diymediahome.org)
- [保存]をクリックします
あなたのサイトからGoogleプロフィールへのリンクを追加
今、私たちは、Googleプロフィールにあなたの著者ページからリンクを追加する必要があります. あり 2 これを行うにはALTERN-AT-IVEの方法, 私は非常にヨーストを使用して推奨つくろう この プラグイン.
- インストール ヨースト この PLU-GIN または あなたのテーマのfunctions.phpのファイルに次のコードを追加します123456789function update_contactmethods( $contactmethods ) {// Add Google Profiles$contactmethods[‘googleplus’] = ‘Google+’;// Add Twitter$contactmethods[‘twitter’] = __( ‘Twitter username (without @)’, ‘wordpress-seo’ );return $contactmethods;}add_filter( ‘user_contactmethods’, ‘update_contactmethods’, 10, 1);
- WordPressの管理画面で、あなたの著者プロフィールに行く (hover over ユーザー 左側のメニューで, 、をクリックして下さい あなたのプロファイル)
- で Google+の フィールドには、Googleのプロファイルへのリンクを追加 (例えば. https://plus.google.com/104657888470728381512 /)
- もしどちらかを確認してください, or your other site authors do the same thing, 自分のGoogleプロフィールへの各リンク
- 今, あなたはヨーストPLU-GINを使用している場合, に行く この メニューを選択 タイトルやメタ情報, C言語でなめる ホームホーム ページの上部にあるとのメニュー 高光INGのオーサリング プルダウンボックスでは、ホームページの作成者として使用したいユーザーを選択
- あなたが手動header.phpのために、次のコードを追加する必要がありますヨーストプラグインを使用していない約執拗なら (仮定して、1つを持っている). Don’t forget to change my google profile url to yours. This code will use the post author’s google profile url if there is a valid one, およびデフォルトを使用します (あなた) 存在しない場合.1<link rel=“author” href=”<?php $gplus = ‘https://plus.google.com/115369062315673853712/posts’; if ( is_singular() ) {global $post; $gplus = get_the_author_meta( ‘googleplus’, $post->post_author );} echo $gplus; ?>”/>
Fix errors of a missing “updated” field
ほとんどのWordpressのテーマは、ポストは、ポスト情報エリアに掲載された際の情報が含まれ, それが最後に更新されたときには非常に少数にも含まれ. これは残念です, because updated is required whereas published actually isn’t! それを追加することも簡単です, そして再び, がある 2 方法, the proper way and the quick hack way. I recommend the proper way of course, しかし、必要に応じて迅速なハックに頼ることができます. また、同時にマイクロフォーマットからミクロに変更しようとしている.
適切な方法
We’re going to add some additional information to post headers, 検索エンジンのための、私たちのVIS-IT的論理和をとり、両方. 我々はポストのためにこれを行う必要があります, ページ, アーカイブとホームページ.
- 私たちは、公開されたリンクを生成するコードを含むファイルを見つける必要がある. これはほぼ確実にWordPressの機能を使用します get_the_date(). あなたのテーマファイルを検索することができます, or refer to theme specific details below where I have provided details for lots of themes
- 私たちは、出版され、更新された日付が同じであるかどうかを確認しようとしている. その場合、我々は単に余分に追加されます dateUp時代遅れ itempropしかし、彼らが異なっている場合、我々は、出力の訪問者にいくつかの余分なテキストをう
- 私たちは、FOL低INGを追加しようとしている (and modify it as it explains)1234567891011121314151617<?php if(get_the_date()==get_the_modified_date()): ?>//we’re going to use the original code just with the updated class added//put your theme’s original code here//remove any class=””//add itemprop=“datePublished dateCreated dateModified” to the HTML tag surrounding the get_the_date() function<?php else: ?>//we’re going to use slightly code just with the updated date added//copy your theme’s original code to here and then modify it as below//remove any class=””//add itemprop=“datePublished dateCreated” to the HTML tag surrounding the get_the_date() function//add in a new html tag into the line where you want it to appear as below//Updated <?php echo get_the_modified_date() ?><?php endif; ?>
- You’ll either have to figure out the original theme’s code and edit it, or refer to the details for specific themes below.
- 複数のファイルのためにこの編集を繰り返す必要があります
クイックハック
我々は、更新された日付などの発行日をカンニングして供給するつもりだ, ポストは、実際には、より最近に更新されている場合でも、. 投稿が更新されているならば、我々は実際に間違った情報を提供することでしょう, それはまだヴァル-ID-食べます. それは実際に可能であれば適切にそれを行うことをお勧めします, あなたがそれを行う上で執拗ならが、この方法では、読み. 上記のように、我々はポストのためにこれを行う必要があります, ページ, アーカイブとホームページ.
- 私たちは、公開されたリンクを生成するコードを含むファイルを見つける必要があり、上記のように. これはほぼ確実にWordPressの機能を使用します get_the_date(). あなたのテーマファイルを検索することができます, または私はテーマの多くの詳細を提供してきた以下の表を参照してください。
- 見つける HTMLの 日付をシュール丸めエレメントメント (しばしば、それが持っているでしょう
class="published"
). - クラスを削除し、代わりに以下を追加して、要素を編集
itemprop="datePublished dateCreated dateUpdated"
- 上記のように, あなたは複数のファイルで、この編集を繰り返す必要があります
Replacing the built-in microformats (because mixing rich snippet formats breaks things)
デフォルトのワードプレスで、まだコメントをマイクロフォーマットのマークアップを使用しています, 悲しいことに、レシピのようなもののミクロデータのマークアップを破るように思われる. この問題を解決する最良の方法は、マイクロフォーマットのマークアップを削除し、ミクロデータマークアップと交換することです. Unfor-TU-nately, これには約いじっのビットを必要とするので、このマークアップを生成するWordPressのコア機能は、便利な場所にフィルタやフックを持っていない.
Replacing vcard in the comments section
- 私たちがやろうとしていることは、コメントの出力を変更するには、コメントのコールバックを使用している. Many themes already use a callback which we can modify, とそうでないもののために私たちはWordPressのデフォルトに基づいて1を追加します
- あなたのテーマを既にコメントのコールバックを持っているかどうかを確認します - 関数のあなたのテーマファイルを検索
wp_list_comments
. それは、コードが含まれている場合callback=
また'callback' =>
それはあなたが見つけることができる必要があり、コールバックを使用しています (確率巧みのfunctions.php内) コールバック関数の名前を探すこと, =記号や矢印の後にその一部である, 例えば.wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
またwp_list_comments('type=comment&callback=bones_comments');
. If it doesn’t then we will need to add one by addingcallback=diymh_comment
またarray( 'callback' => 'diymh_comment' )
ラインへ. - あなたはコメントのコールバックを追加するために必要な場合、あなたはのfunctions.phpに次のコードを追加する必要があります123456789101112131415161718192021222324function diymh_comment($comment, $args, $depth) {$GLOBALS[‘comment’] = $comment; ?><li <?php comment_class(); ?> id=“li-comment-<?php comment_ID() ?>”><div id=“comment-<?php comment_ID(); ?>”><div class=“comment-author novcard”><?php echo get_avatar($comment,$size=‘48’,$default=’<path_to_url>’ ); ?><?php printf(__(‘<cite class=“fn”>%s</cite> <span class=“says”>says:</span>’), get_comment_author_link()) ?></div><?php if ($comment->comment_approved == ‘0’) : ?><em><?php _e(‘Your comment is awaiting moderation.’) ?></em><br /><?php endif; ?><div class=“comment-meta commentmetadata”><a href=”<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>”><?php printf(__(‘%1$s at %2$s’), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__(‘(Edit)’),’ ‘,”) ?></div><?php comment_text() ?><div class=“reply”><?php comment_reply_link(array_merge( $args, array(‘depth’ => $depth, ‘max_depth’ => $args[‘max_depth’]))) ?></div></div><?php}
- あなたは、このコードが持っていることがわかります
class="novcard"
instead of the originalclass="vcard".
- あなたのテーマは、独自のコールバックを持っていなかった場合は、コールバック関数を見つけ、任意のインスタンスを置換する必要があります
class="vcard"
とともにclass="novcard"
Replacing hfeed in the header
- 次, 我々はまた、任意のインスタンスを削除する必要があります
class="hfeed"
, これ有珠同盟国header.phpの中で発見された. すべての発生·rencesを交換してくださいhfeed
とともにnohfeed
Replacing hentry and title rich snippets
- 私たちは、のfunctions.phpに追加きちんと機能のカップルと、これらの要素を置き換えることができます12345678910function diymh_replace_hentry($classes){if(($key = array_search(‘hentry’, $classes)) !== false) $classes[$key]=‘nohentry’;return $classes;}add_filter(‘post_class’,‘diymh_replace_hentry’);function diymh_microdata_title($title) {return ‘<span itemprop=“name”>’.$title.’</span>’;}add_filter(‘the_title’, ‘diymh_microdata_title’, 10, 2);
Adding the information type (例えば. Article, レシピ, その他) to the article header
- 最初の, decide what type of work you are publishing — most likely an article. Have a look at the list at schema.org
- 見つける HTMLの タグこれCON-TAINS機能のTiON
post_class()
- コードを追加します。
itemscope itemtype="https://schema.org/Article"
(あなたが仕事の様々なタイプを選んだ場合は、記事を交換してください)
最後に, to avoid breaking any styles
- あなたのテーマのstyle.cssにを編集する必要があり、すべてのインスタンスのを置き換えるために、検索/置換操作を行います
.vcard
とともに.novcard
とのすべてのインスタンスを置き換える.hfeed
とともに.nohfeed
私たちの変更は、いずれかの混乱をしないように CSS コメントのSTYL-ING
Fixing any other errors
Any other changes necessary will be detailed on a per theme basis below. あなたが修正することができないテーマがある場合はコメントを投稿してください. その自由なテーマなら、私はテーマ名を教えてください, and if it is a premium theme please let me know so I can provide you with an e‑mail address to send a zipped copy to.
Theme specific details
Before just carrying out these edits don’t forget to carry out the steps to link your google profile and your site to each other, とヨーストをインストール この, 以上提供するコードを追加します.
二十テン 1.5
のfunctions.phpでこれを置き換える
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | function twentyten_posted_on() { printf( __( ‘<span class=”%1$s”>Posted on</span> %2$s <span class=“meta-sep”>by</span> %3$s’, ‘twentyten’ ), ‘meta-prep meta-prep-author’, sprintf( ‘<a href=”%1$s” title=”%2$s” rel=“bookmark”><span class=“entry-date”>%3$s</span></a>’, get_permalink(), esc_attr( get_the_time() ), get_the_date() ), sprintf( ‘<span class=“author vcard”><a class=“url fn n” href=”%1$s” title=”%2$s”>%3$s</a></span>’, get_author_posts_url( get_the_author_meta( ‘ID’ ) ), esc_attr( sprintf( __( ‘View all posts by %s’, ‘twentyten’ ), get_the_author() ) ), get_the_author() ) ); } |
これとともに
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | function twentyten_posted_on() { if(get_the_date()==get_the_modified_date()){ printf( __( ‘<span class=”%1$s”>Posted on</span> %2$s <span class=“meta-sep”>by</span> %3$s’, ‘twentyten’ ), ‘meta-prep meta-prep-author’, sprintf( ‘<a href=”%1$s” title=”%2$s” rel=“bookmark”><span itemprop=“datePublished dateCreated dateModified”>%3$s</span></a>’, get_permalink(), esc_attr( get_the_time() ), get_the_date() ), sprintf( ‘<span class=“author vcard”><a itemprop=“author” href=”%1$s” title=”%2$s”>%3$s</a></span>’, get_author_posts_url( get_the_author_meta( ‘ID’ ) ), esc_attr( sprintf( __( ‘View all posts by %s’, ‘twentyten’ ), get_the_author() ) ), get_the_author() ) ); } else{ printf( __( ‘<span class=”%1$s”>Posted on</span> %2$s <span class=“meta-sep”>by</span> %3$s. Updated <span itemprop=“dateModified”>%4$s</span>.’, ‘twentyten’ ), ‘meta-prep meta-prep-author’, sprintf( ‘<a href=”%1$s” title=”%2$s” rel=“bookmark”><span itemprop=“datePublished dateCreated”>%3$s</span></a>’, get_permalink(), esc_attr( get_the_time() ), get_the_date() ), sprintf( ‘<span class=“author vcard”><a itemprop=“author” href=”%1$s” title=”%2$s”>%3$s</a></span>’, get_author_posts_url( get_the_author_meta( ‘ID’ ) ), esc_attr( sprintf( __( ‘View all posts by %s’, ‘twentyten’ ), get_the_author() ) ), get_the_author() ), get_the_modified_date() ); } } |
のfunctions.phpでこれを置き換える
336 | <div class=“comment-author vcard”> |
これとともに
336 | <div class=“comment-author novcard”> |
header.phpの中で、これを交換してください
56 | <div id=“wrapper” class=“hfeed”> |
これとともに
56 | <div id=“wrapper” class=“nohfeed”> |
loop.php中 (3 インスタンス), ループsingle.php, ループpage.phpとループattachment.phpはこれを交換する
1 | <div id=“post-<?php the_ID(); ?>” <?php post_class(); ?> |
これとともに
1 | <div id=“post-<?php the_ID(); ?>” <?php post_class(); ?> itemscope itemtype=“http://schema.org/Article”> |
二十セブンイレブン 1.5
非常にすぐにCOM-ING ...
Annotumベース 1.1.1
で 7 ファイル (機能特徴 - articles.php, 抜粋タイプ - article.php, 抜粋抜粋 - default.php, コンテンツタイプ - article.php, コンテンツの page.php, コンテンツのコンテンツdefault.php, コンテンツ物品pdf.php) 交換する
1 | <article <?php post_class(‘article-full’); ?> |
とともに
1 | <article <?php post_class(‘article-full’); ?> itemscope itemtype=“http://schema.org/Article”> |
下記のコメントで私達にあなたの考えを送ってください! あなたが購読したい場合は、右上のメニューで購読リンクをご利用ください. また、下記の社会的なリンクを使用してお友達とこれを共有することができます. 乾杯.
Thanks — working on it — eisenberg.co.za
すばらしいです, grazie mille!