WooCommerce - show only parent category title

  • 状态 完成的
  • 预算 zł30 - zł90 PLN
  • 总竞标 15

项目描述

I have a very simple job.

This script displays in my shop categories to which the product belongs.:

global $post, $product;

$cat_count = sizeof( get_the_terms( $post->ID, 'product_cat' ) ); ?>

<div class="cat_title"><?php echo $product->get_categories( ', ', '<span class="posted_in">' . _n( '', '', $cat_count, 'woocommerce' ) . ' ', '</span>' );?></div>

I want to list the name ONLY parent category, without sub-categories.

Currently, the script displays a parent category and its subcategories. Must display only parent category.

获得类似项目的报价
完成的:
要求的技能

想赚钱吗?

  • 设置你的预算和期限
  • 列出你的提案
  • 获得工资

雇用同样在该项目上竞标的威客

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online