By default, WooCommerce adds your categories on the single product pages.
Normally, they are displayed under the ‘Add to cart’ button.
I’m talking about this:
Unfortunately, WooCommerce doesn’t have a built-in setting to remove it, but I’ll show you how to easily do it without a plugin!
The fewer plugins you have, the better!
Remove Category from WooCommerce Product Page
Before doing this, I recommend backing up your site or the functions.php
file, just to be safe.
I also recommend having a child theme, otherwise, the changes will be gone with the next theme update.
If you don’t have a child theme, then use the Code Snippets plugin and add the code there.
For my example, I’ll use cPanel and a child theme.
Step 1
Access your WordPress theme files to edit functions.php
found in your child theme’s folder.
This is the usual path:
public_html/wp-content/themes/YourThemeName-child/functions.php
Step 2
Add the following line of code right at the bottom of the file or right above the ?>
ending tag (if any).
/* Remove Categories from Single Products */
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
Save the file.
Final step
It will most likely be necessary to clear your site and browser cache in order to see the change.
Alternative: Hide Category from WooCommerce Product Page
While this method is simpler, it’s not the best on-page SEO practice because Google is not a fan of hiding content, especially when there are links involved.
Anyway, it might still be necessary.
So, add this CSS code in WordPress:
.product_meta .posted_in {display: none;}
Here’s how to add custom CSS in WordPress.
It might be necessary to clear your site and browser cache.
If the change still doesn’t take place after that, add !important
to the code, like this:
.product_meta .posted_in {display: none !important;}
If it still doesn’t work, it might be that your theme modified the CSS selectors, and you’ll need to find them yourself.
That’s a Wrap
I hope you found this tutorial useful, and you managed to remove the category from the WooCommerce product page!
If you have any questions or thoughts, drop a comment or send a message via contact or Facebook page.
You can also hit the follow button on Twitter and subscribe to the YouTube channel.
Don’t forget to share the post to help out others!
I was looking for a CSS code for hiding categories on product pages and used your code. Worked great. Thanks.
That’s great! Thanks for letting me know.
Thanks a lot :)
You’re welcome! :D
Is there a code that only removes categories from WooCommerce product page for mobile devices? (and still have it on the tablet and desktop version)
Any ideas how how to just disable one or 2 categories from being shown here? as opposed to hiding the whole section? So for example product is in 2 categories, 1 is cat, and one is dog
i want dog to be displayed here, but cat to be hidden?
Thanks
Hello, I’m looking for this too, did you find a solution?
Top stuff!!! If only all fixes were this elegantly explained. Two-minuters ROCK!!! Sooooo many thanks!!!