This topic has 6 replies, 2 voices, and was last updated 3 years, 1 months ago ago by Olga Barlow
Hi again,
Another question, I’d like to show Categories above the product name in single product page. And I want to change the colors.
How can I manage it?
Thank you,
Youkila
Hello,
Do you use a built-in single product layout or a single product builder?
Regards
Hi Olga Barlow,
Thank you for contacting me.
I’m using a built-in single product layout.
Best,
Youkila
Hello,
There is no such option. But you may try to use WooCommerce hooks to implement this by additional customization.
For example, add the below code to child theme functions.php
function custom_single_product_category(){
$product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
if ( $product_cats && ! is_wp_error ( $product_cats ) ){
$single_cat = array_shift( $product_cats ); ?>
<h2 itemprop="name" class="product_category_title"><span><?php echo $single_cat->name; ?></span></h2>
<?php }
}
add_action( 'woocommerce_single_product_summary', 'custom_single_product_category', 2 );
Regards
Hi Olga Barlow,
Thank you for your reply.
It works but display only one category.
Actually each products has several categories in my site.
Is it possible to show every categories as meta field?
Thank you very much in advance.
Youkila
Hello,
Then replace the previous code by this one
add_action( 'woocommerce_single_product_summary', 'etheme_product_cats', 2 );
And don’t choose Primary category in the single product settings https://prnt.sc/1wtkawh
Regards
Tagged: best selling, categories, product name, seo friendly, themes, woocommerce
You must be logged in to reply to this topic.Log in/Sign up