Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce: Display Category Name

Is there a way to display the product category name on the WooCommerce archive-product.php page.

My product category name is "Bracelets", and I'd like that to be displayed as a title on the page.

I'm using wp_title() currently:

<h1><?php wp_title(); ?></h1>

But that prints it to the page like this:

» Product Categories » Bracelets

I'm getting the parent page title and the catgeory name with separators in between them (above).

Is there any way I can get the title to print just "Bracelets"?

Any help with this is appreciated.

Thanks in advance!

like image 331
realph Avatar asked Nov 04 '14 22:11

realph


People also ask

How do I display a particular category product in WooCommerce shortcode?

These two shortcodes will display your product categories on any page. [product_category] – Will display products in a specified product category. [product_categories] – Will display all your product categories.


2 Answers

You're looking for single_term_title():
https://developer.wordpress.org/reference/functions/single_term_title/

like image 199
diggy Avatar answered Oct 04 '22 04:10

diggy


Currently you can display product categories this way (Wordpress 4.x):

<?php echo wc_get_product_category_list($product->get_id()) ?>
like image 22
Okto Avatar answered Oct 04 '22 04:10

Okto