WooCommerce: Hide Category & Tag @ Single Product Page

SKU, Category list and Tag list on the WooCommerce single product page are called “product meta”. We already saw how to hide just the SKU (while leaving Cats and Tags there), so in this “episode” we will study how to do the opposite i.e. keeping the SKU there while hiding Cats and/or Tags.

If you are a developer, you’d think there were a specific WooCommerce “filter” for this, but there is not. So, we have to first remove the whole “product meta” block and then add back the info we want (just the Cats, for example). If you’re not a dev – not to worry – just copy paste one of the snippets below in your functions.php and magic will happen. Enjoy!

We’re looking at the “Product Meta” section on the single product page. Our goal is to hide categories and tags and leave SKU where it is now.

PHP Snippet 1: Hide β€œSKU” & “Category:__” & “Tag:__” @ WooCommerce Single Product Page

Basically, in here we go and remove the whole “Product Meta” block. And thankfully, it’s just 1 line of code.

If you want to add back just the SKU, just the Cats or just the Tags, use snippet 2, 3 or 4 together with this one.

/**
 * @snippet       Hide SKU, Cats, Tags @ Single Product Page - WooCommerce
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WC 3.8
 * @community     https://businessbloomer.com/club/
 */
  
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

PHP Snippet 2: Show β€œSKU”Again @ WooCommerce Single Product Page

This is equivalent to saying “Hide Categories and Tags” from product meta. Basically after removing the whole product meta block, we’re readding the SKU.

/**
 * @snippet       Show SKU Again @ Single Product Page - WooCommerce
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WC 3.8
 * @community     https://businessbloomer.com/club/
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_show_sku_again_single_product', 40 );

function bbloomer_show_sku_again_single_product() {
   global $product;
   ?>
   <div class="product_meta">
   <?php if ( wc_product_sku_enabled() && ( $product->get_sku() || $product->is_type( 'variable' ) ) ) : ?>
      <span class="sku_wrapper"><?php esc_html_e( 'SKU:', 'woocommerce' ); ?> <span class="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : esc_html__( 'N/A', 'woocommerce' ); ?></span></span>
   <?php endif; ?>
   </div>
   <?php
}


PHP Snippet 3: Show β€œCategories:” Again @ WooCommerce Single Product Page

/**
 * @snippet       Show Categories Again @ Single Product Page - WooCommerce
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WC 3.8
 * @community     https://businessbloomer.com/club/
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_show_cats_again_single_product', 40 );

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


PHP Snippet 4: Show β€œTags:” Again @ WooCommerce Single Product Page

/**
 * @snippet       Show Tags Again @ Single Product Page - WooCommerce
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WC 3.8
 * @community     https://businessbloomer.com/club/
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_show_tags_again_single_product', 40 );

function bbloomer_show_tags_again_single_product() {
   global $product;
   ?>
   <div class="product_meta">
   <?php echo wc_get_product_tag_list( $product->get_id(), ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', count( $product->get_tag_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?> 
   </div>
   <?php
}


Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

36 thoughts on “WooCommerce: Hide Category & Tag @ Single Product Page

  1. doent work anymore

    1. It does on my dev site! What theme are you on?

  2. Still working!
    Thanks!

  3. Hello Rodolfo, I used this code for a time now (thanks!!!!!), but since the latest update (Woo 6.8.2 / WP 6.0.2) it doesn’t seem to work anymore. Did Woocommerce change their hooks or something? Or do I need to check the Theme (Astra 3.9.2)?

    Also a code like “remove_action(‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10);” does not work anymore.

    Please advice.

    Thanks,
    Denny

    1. Hi Denny! Woo didn’t change hooks, so it could be Astra or another plugin. Try with 2021 theme and only Woo active and see if it works.

  4. Hi,

    Incredibly quick fix, is there a way to hide just 1 specific tag from Single Product Pages?

    1. Hty JosΓ©, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Thanks it works perfectly

  6. Big thanks. Worked perfectly on Astra free theme Life Coach with WooCommerce and Tutor LMS using Code Snippets (coding is above my brain capacity, so really appreciated this help:)). Stay safe!

  7. doesn’t work anymore ?

    1. Hi Roy, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet.

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentytwenty” theme (load the snippet there in functions.php) as explained here: https://www.businessbloomer.com/lesson/trwm4l01/

      Once you do that, does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!

  8. The code is great, but it doesn’t work on the custom product page layout, tried the same line of code, and also tried to work it through by changing the code but no results, it only works on the default woocommerce product layout.

    1. Spot on, all my snippets are for default WooCommerce

      1. I’m using Beaver Themer to create custom single product page layouts (Astra Pro theme). SKU and Categories can be hidden with the following CSS:

        .woocommerce div.product .product_meta > span.sku_wrapper {
        	display: none;
        }
        .woocommerce div.product .product_meta > span.posted_in {
        	display: none;
        }

        If you need to remove Tags you can use:

        .woocommerce div.product .product_meta > span.tagged_as {
        	display: none;
        }
        
  9. Awesome, I love the simplicity of this fix, thanks a lot

    1. Cool!

  10. Perfect quick fix – thanks man!

    1. You’re welcome!

  11. Hi, I loved your tutorials on changing things around Woocommerce. I had a similar question regarding this. I want to remove the category meta data that shows on all products while browsing. So lets say, When you open your products page, your products are displays and for each product below their image, it displays the categories that the product is listed under before the short description. I would like to remove that specific category meta data display from the products. Can you assist on which code to use for that? I looked everywhere but couldnt find any solution to this.

    1. Doesn’t this snippet help?

  12. Hello there, I am having a little problem trying to remove the commas in between the product tags, can anyone point me in the right direction please?

    1. Hi Alal, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  13. Your site is awesome. Thank you for all the tips and tricks as I dip my toe into the world of woocommerce.

    Interestingly enough, I have put all of your (and other) code snippets in ~/wp-includes/functions.php and they’ve all worked, except this one. I had to put this one in where you actually suggest doing it (which i probably should have been doing anyways) in ~/wp-content/themes/customify/functions.php. I can only assume that the ~/wp-includes/functions.php file is not being called for that command? Just wondering if you have any insights on that. Thanks again.

    1. /wp-includes/functions.php is just wrong as you will override that every time you update WordPress. The ideal is your child theme’s functions.php, which is never overwritten

      1. Thanks! (Making Corrections now) πŸ™‚

  14. Great one, as well as all the other tips and snippets that You post.
    Thank You so much!

    1. Thanks!

  15. Awesome… It Works.

    1. Brilliant

  16. Is there an easy way to make the SKU and category display in a single row rather than two rows?

    1. Hi Biff, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

      1. It works perfect, Thank for the help.

        1. Cool!

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *