掲題の件で行き詰まっております。
テーマはwoocommerceと互換性のないテーマを使用。
下記の情報を参考に、編集する対象のファイルは既存のテーマに
移行して編集しています。
http://highfivecreate.com/blog/course/tips/2279.html
【問題点】
商品の一覧を表示するarchive-product.phpのパンくずリスト(sample1)が表示されない。また下図のように2つのパーマリンクが表示されてしまいます。woocommerce側で生成されているパーマリンクはちゃんと表示されているのですが、スタイリングがされていない状態です。
下図はsingle-product.phpのページを開いた状態です。
【やったこと】
woocommerceのパンくずリストを消去し、表示を確認してみる。
案の上、既存のテーマのパンくずリストは表示されるが、sample1の
パンくずリストが表示されない。
* woocommerceのパンくずリストを消去する */ add_action( 'init', 'jk_remove_wc_breadcrumbs' ); function jk_remove_wc_breadcrumbs() { remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); }
【解決したい事】
archive-product.phpとarchive-product.phpのファイルのパンくず以下のように修正したいです。
■archive-product.phpで解決したいこと(画像付)
・既存のパンくずとwoocommerceのパンくず両方が表示されているので1つだけの表示に設定したい。
・もしwoocommerceのパンクズを残すなら既存のテーマのようなパンくずのスタイルに整えたい(アイコン付)
・もし既存のテーマのパンクズを残すならsample1が表示されないので表示するように設定したい
↓現在の表示の状態↓
■single-product.phpで解決したいこと(画像付)
・archives-product.phpのときと同じくsample1のパンくずの箇所が表示されていないので表示したい
・Home>sample1>ヘアエステshampooーのはずなのに、なぜかHome>極上シャンプー>ヘアエステshampooと表示されているので、Home>sample1>ヘアエステshampooとなるように表示させたい。
↓現在の表示の状態↓
以上、既存テーマのようにスタイリングをきかせてパンくずリストを表示させる解決策をご教示頂ければありがたいです。
追記:
既存テーマのパンくずのコードです。
既存テーマのfunction.phpに記述しています。
//パンくずナビ function breadcrumb($divOption = array("id" => "breadcrumb", "class" => "breadcrumb inner wrap cf")){ global $post; $str =''; if(!is_home()&&!is_front_page()&&!is_admin()){ $tagAttribute = ''; foreach($divOption as $attrName => $attrValue){ $tagAttribute .= sprintf(' %s="%s"', $attrName, $attrValue); } $str.= '<div'. $tagAttribute .'>'; $str.= '<ul>'; $str.= '<li itemtype="//data-vocabulary.org/Breadcrumb"><a href="'. home_url() .'/" itemprop="url"><i class="fa fa-home"></i><span itemprop="title"> ホーム</span></a></li>'; if(is_category()) { $cat = get_queried_object(); if($cat -> parent != 0){ $ancestors = array_reverse(get_ancestors( $cat -> cat_ID, 'category' )); foreach($ancestors as $ancestor){ $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><a href="'. get_category_link($ancestor) .'" itemprop="url"><span itemprop="title">'. get_cat_name($ancestor) .'</span></a></li>'; } } $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><span itemprop="title">'. $cat -> name . '</span></li>'; } elseif(is_single()){ $categories = get_the_category($post->ID); $cat = $categories[0]; if($cat -> parent != 0){ $ancestors = array_reverse(get_ancestors( $cat -> cat_ID, 'category' )); foreach($ancestors as $ancestor){ $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><a href="'. get_category_link($ancestor).'" itemprop="url"><span itemprop="title">'. get_cat_name($ancestor). '</span></a></li>'; } } $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><a href="'. get_category_link($cat -> term_id). '" itemprop="url"><span itemprop="title">'. $cat-> cat_name . '</span></a></li>'; $str.= '<li itemtype="//data-vocabulary.org/Breadcrumb">'. $post -> post_title .'</li>'; } elseif(is_page()){ if($post -> post_parent != 0 ){ $ancestors = array_reverse(get_post_ancestors( $post->ID )); foreach($ancestors as $ancestor){ $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><a href="'. get_permalink($ancestor).'" itemprop="url"><span itemprop="title">'. get_the_title($ancestor) .'</span></a></li>'; } } $str.= '<li itemtype="//data-vocabulary.org/Breadcrumb"><span itemprop="title">'. $post -> post_title .'</span></li>'; } elseif(is_date()){ if( is_year() ){ $str.= '<li>' . get_the_time('Y') . '年</li>'; } else if( is_month() ){ $str.= '<li><a href="' . get_year_link(get_the_time('Y')) .'">' . get_the_time('Y') . '年</a></li>'; $str.= '<li>' . get_the_time('n') . '月</li>'; } else if( is_day() ){ $str.= '<li><a href="' . get_year_link(get_the_time('Y')) .'">' . get_the_time('Y') . '年</a></li>'; $str.= '<li><a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('n') . '月</a></li>'; $str.= '<li>' . get_the_time('j') . '日</li>'; } if(is_year() && is_month() && is_day() ){ $str.= '<li>' . wp_title('', false) . '</li>'; } } elseif(is_search()) { $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><span itemprop="title">「'. get_search_query() .'」で検索した結果</span></li>'; } elseif(is_author()){ $str .='<li itemtype="//data-vocabulary.org/Breadcrumb"><span itemprop="title">投稿者 : '. get_the_author_meta('display_name', get_query_var('author')).'</span></li>'; } elseif(is_tag()){ $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><span itemprop="title">タグ : '. single_tag_title( '' , false ). '</span></li>'; } elseif(is_attachment()){ $str.= '<li itemtype="//data-vocabulary.org/Breadcrumb"><span itemprop="title">'. $post -> post_title .'</span></li>'; } elseif(is_404()){ $str.='<li>ページがみつかりません。</li>'; } else{ $str.='<li itemtype="//data-vocabulary.org/Breadcrumb"><span itemprop="title">'. wp_title('', true) .'</span></li>'; } $str.='</ul>'; $str.='</div>'; } echo $str; }
宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー