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!
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
}
doent work anymore
It does on my dev site! What theme are you on?
Still working!
Thanks!
Awesome!
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
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.
Hi,
Incredibly quick fix, is there a way to hide just 1 specific tag from Single Product Pages?
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!
Thanks it works perfectly
Nice
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!
Excellent!
doesn’t work anymore ?
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!
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.
Spot on, all my snippets are for default WooCommerce
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:
If you need to remove Tags you can use:
Awesome, I love the simplicity of this fix, thanks a lot
Cool!
Perfect quick fix – thanks man!
You’re welcome!
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.
Doesn’t this snippet help?
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?
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!
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.
/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
Thanks! (Making Corrections now) π
Great one, as well as all the other tips and snippets that You post.
Thank You so much!
Thanks!
Awesome… It Works.
Brilliant
Is there an easy way to make the SKU and category display in a single row rather than two rows?
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!
It works perfect, Thank for the help.
Cool!