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!
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.
You're looking for single_term_title()
:
https://developer.wordpress.org/reference/functions/single_term_title/
Currently you can display product categories this way (Wordpress 4.x):
<?php echo wc_get_product_category_list($product->get_id()) ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With