categories - How do you remove display of WooCommerce product category on single product page?

admin2025-06-05  0

On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.

On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.

Share Improve this question asked Nov 4, 2013 at 16:23 user41328user41328 191 gold badge1 silver badge2 bronze badges 1
  • I was researching something else and found the answer! The php file to edit is single-product/meta.php (you can't see this via the Editor from the Dashboard; you need to FTP to get it). I removed: <?php $size = sizeof( get_the_terms( $post->ID, 'product_cat' ) ); echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $size, 'woocommerce' ) . ' ', '.</span>' ); ?> :) – user41328 Commented Nov 4, 2013 at 16:59
Add a comment  | 

2 Answers 2

Reset to default 4

As an alternative to editing the meta template, you can prevent the meta information from being displayed on single product pages at all. This can be handy if you also don't want to display the SKUs. Here is how to do it:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

It goes to your functions.php.

Old question, but I want to point out overriding templates. Nick's answer removes all the meta display. In my case, I only wanted to remove the category and not all the meta information.

Create a copy of single product meta file to yourtheme/woocommerce/single-product/meta.php.

Remove the following line (line 38 on version 3.5):

<?php echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?>

This way, you can update WooCommerce without it overwriting your changes.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749057245a315990.html

最新回复(0)