Reputation: 22
I am trying to get single product category name of a product category archive page.
Using this code:
$categ = $product->get_categories();
echo $categ;
Its showing all parent category as well…
How to get the current term name in Woocommerce product category archive pages?
Upvotes: 1
Views: 4112
Reputation: 253784
To get the product category term name of the current product category archive page, you will use:
// Only on product category archive pages
if(is_product_category()){
// The WP_Term object for the current product category
$term = get_queried_object();
// Get the current term name for the product category page
$term_name = $term->name;
// Test output
echo $term->name . '<br>';
}
Tested and works.
Upvotes: 3