パンくずリストの構造化警告対策[LION MEDIA]
- 2020.02.11
- ITネタ
![パンくずリストの構造化警告対策[LION MEDIA]](https://namotein.com/wp-content/uploads/2020/02/lionblog-data-vocabulary-icon.png)
このブログサイトでは『LION BLOG』テーマを採用しているということで、そのテーマに対する「data-vocabulary.org」に対する対応方法を公開しました。
「data-vocabulary.org」の説明や『LION BLOG』テーマに対する対応方法については「パンくずリストの構造化警告対策[LION BLOG]」にて記載しております。
その後、『LION MEDIA』テーマに対する対応方法を教えてほしいとのご要望がありましたので、対応方法を調査しました。
修正内容は幸い『LION BLOG』テーマとほぼ変わらないことが分かりましたが、このサイトは『LION MEDIA』テーマを使用していないため、警告が解消されるところまでは確認しておりません。解消されたとのフィードバックをいただきました。
あらかじめご了承ください。
対応方法
先ほど説明したとおり、ここでは「LION MEDIA」テーマに特化した方法をご紹介します。
もしも他のテーマを使用しているのであれば、そのテーマの公式サイトにて修正版が配布されているかどうかご確認ください。
なお今回ご紹介する方法は、テーマファイルを修正する方法になります。正常に表示されなくなることもありますので、万が一に備えてバックアップを取ることをおすすめします。あくまでも自己責任でお願いします。
執筆時点のWordpressバージョン:5.3.2
LION MEDIAテーマバージョン:2.0.0
1. WordPressの管理画面にて、[外観]-[テーマエディター]をクリックします

2. テーマを「LION MEDIA」に変更し、テーマファイルを「Theme Functions(functions.php)」をクリックします
※「テーマのための関数(functions.php)」という表示の場合もあります

3. 以下の通りに修正します
変更前
5410行: $str.= '<ul class="breadcrumb__list">';
5411行: $str.= '<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. home_url() .'/" itemprop="url"><span class="icon-home" itemprop="title">'. $home .'</span></a></li>';
変更後
5410行: $str.= '<ol class="breadcrumb__list" itemscope itemtype="http://schema.org/BreadcrumbList">';
5411行: $str.= '<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. home_url() .'/" itemprop="item"><span class="icon-home" itemprop="name">'. $home .'</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5419行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' .get_post_type_archive_link( $cpt ).'" itemprop="url"><span itemprop="title">'. get_post_type_object( $cpt )->label.'</span></a></li>';
変更後
5419行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="' .get_post_type_archive_link( $cpt ).'" itemprop="item"><span itemprop="name">'. get_post_type_object( $cpt )->label.'</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5425行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_term_link( $ancestor, $my_tax->taxonomy ) .'" itemprop="url"><span itemprop="title">'. get_term( $ancestor, $my_tax->taxonomy )->name .'</span></a></li>';
変更後
5425行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_term_link( $ancestor, $my_tax->taxonomy ) .'" itemprop="item"><span itemprop="name">'. get_term( $ancestor, $my_tax->taxonomy )->name .'</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5436行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_category_link( $ancestor ) .'" itemprop="url"><span itemprop="title">'. get_cat_name( $ancestor ) .'</span></a></li>';
変更後
5436行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_category_link( $ancestor ) .'" itemprop="item"><span itemprop="name">'. get_cat_name( $ancestor ) .'</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5450行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' .get_post_type_archive_link( $cpt ).'" itemprop="url"><span itemprop="title">'. get_post_type_object( $cpt )->label.'</span></a></li>';
変更後
5450行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="' .get_post_type_archive_link( $cpt ).'" itemprop="item"><span itemprop="name">'. get_post_type_object( $cpt )->label.'</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5457行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_term_link( $ancestor, $mytax ).'" itemprop="url"><span itemprop="title">'. get_term( $ancestor, $mytax )->name . '</span></a></li>';
変更後
5457行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_term_link( $ancestor, $mytax ).'" itemprop="item"><span itemprop="name">'. get_term( $ancestor, $mytax )->name . '</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5460行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_term_link( $tax, $mytax ).'" itemprop="url"><span itemprop="title">'. $tax -> name . '</span></a></li>';
変更後
5460行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_term_link( $tax, $mytax ).'" itemprop="item"><span itemprop="name">'. $tax -> name . '</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5470行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_category_link( $ancestor ).'" itemprop="url"><span itemprop="title">'. get_cat_name( $ancestor ). '</span></a></li>';
変更後
5470行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_category_link( $ancestor ).'" itemprop="item"><span itemprop="name">'. get_cat_name( $ancestor ). '</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5473行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_category_link( $cat -> term_id ). '" itemprop="url"><span itemprop="title">'. $cat-> cat_name . '</span></a></li>';
変更後
5473行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_category_link( $cat -> term_id ). '" itemprop="item"><span itemprop="name">'. $cat-> cat_name . '</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5481行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_permalink( $ancestor ).'" itemprop="url"><span itemprop="title">'. get_the_title( $ancestor ) .'</span></a></li>';
変更後
5481行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_permalink( $ancestor ).'" itemprop="item"><span itemprop="name">'. get_the_title( $ancestor ) .'</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5489行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_year_link(get_query_var('year')). '" itemprop="url"><span itemprop="title">' . get_query_var( 'year' ). '年</span></a></li>';
5490行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_month_link(get_query_var( 'year' ), get_query_var( 'monthnum' ) ). '" itemprop="url"><span itemprop="title">'. get_query_var( 'monthnum' ) .'月</span></a></li>';
変更後
5489行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_year_link(get_query_var('year')). '" itemprop="item"><span itemprop="name">' . get_query_var( 'year' ). '年</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
5490行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_month_link(get_query_var( 'year' ), get_query_var( 'monthnum' ) ). '" itemprop="item"><span itemprop="name">'. get_query_var( 'monthnum' ) .'月</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5495行: $str.='<li class="breadcrumb__item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'. get_year_link( get_query_var('year') ) .'" itemprop="url"><span itemprop="title">'. get_query_var( 'year' ) .'年</span></a></li>';
変更後
5495行: $str.='<li class="breadcrumb__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="'. get_year_link( get_query_var('year') ) .'" itemprop="item"><span itemprop="name">'. get_query_var( 'year' ) .'年</span><meta itemprop="position" content="'. ++$position .'" /></a></li>';
変更前
5528行: $str.='</ul>';
変更後
5528行: $str.='</ol>';
4. 終わったら一番下にある「ファイルを更新」をクリックし完了です
5. 表示に問題がないかどうか確認してください
まとめ
パンくずリストの構造化警告への対策方法をご紹介しました。
もしも「 data-vocabulary.org 」を使用したままですと、検索順位にも影響があるかもしれませんので、早めの対応をおすすめします。
また冒頭で記載したとおり、警告が解消されるかまでの確認はできておりませんので、フィードバックをいただけると非常にありがたいです。解消されたとのフィードバックをいただきました。
-
前の記事
プログラミング教育とは?必修化にあたり内容を解説 2020.02.07
-
次の記事
『世界一やさしい問題解決の授業』(ダイヤモンド社) 2020.02.23