php - Show the subcategory name based on current product

Hi I can display subcategory name in current product page (single product page) but it showed all the subcategory name.

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>';

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745388184a4625535.html

相关推荐

  • php - Show the subcategory name based on current product

    Hi I can display subcategory name in current product page (single product page) but it showed all the subcategory name.

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信