最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Show the subcategory name based on current product

programmeradmin1浏览0评论

Hi I can display subcategory name in current product page (single product page) but it showed all the subcategory name. I just want to show subcategory name based on the product selected.

I have one category with two subcategories "black and blue". product A have black subcategory, product B have blue subcategory. when I go to product A, it show black and blue subcategory. All I want is when I go to product A, it only show black subcategory.

here my code

$args = array(
 'hierarchical' => 1,
 'show_option_none' => '',
 'hide_empty' => true,
 'parent' => 106,
 'taxonomy' => 'product_cat'
);
$subcats = get_categories($args);
echo '<p class=breadcrumb_single>Subject ';
foreach ($subcats as $sc) {
$link = get_term_link( $sc->slug, $sc->taxonomy );
  echo '<b><a href="'. $link .'">'.$sc->name.'</a></b>&nbsp;';
}
echo '</p>';
发布评论

评论列表(0)

  1. 暂无评论