WooCommerce Remove a Category from SHOP Page

WooCommerce is an exciting plugin. It gives you everything you need to run an eCommerce site. And when it’s all about business you need the best solution. As I always advice that you should not make permanent edit if you are not sure what you are doing. If you have any doubt or unsure about something then it’s always good to consult an expert.

Moving back to topic. If you need to hide a specific category from WooCommerce shop (Yes, the Product Page) then you can use this code: I’ll explain it as we follow.

add_filter( 'get_terms', 'get_subcategory_terms',10,3 );
function get_subcategory_terms( $terms, $tax, $args ) {
	if( is_shop()){
		foreach($terms as $term){
			if($term->slug == 'us' || $term->slug == 'jeans' ){

				$new_terms[] = $term;
		return $new_terms; 
	return $terms;	

FAQ About the code above

Where am I supposed to paste this code.

You should paste this code into your theme’s functions.php file.

What changes should I make in the code?

Since the above code is custom code and few things will vary depending upon your WooCommerce terms. In the code above look at this line:

if($term->slug == 'us' || $term->slug == 'jeans' )

‘us’ and ‘jeans’ are the categories which are supposed to be removed. If you like to remove just one category then you can remove the pipe sign (||) and remove the second condition like this:

if($term->slug == 'us')

Easy enough!

Code Explaination:

Although not everyone needs explanation but as I always like to educate my client (if they like to) about what and how something is being done on their site, so here it is:

First line is about adding a filter to get_terms. More about Filters.

It means whenever terms (category) are being fetched run a custom function. In our case it is : get_subcategory_terms.

And what this function doing is: If the page in focus is shop page (is_shop) filter the terms and remove desired categories from the array. Then return the array back to the filter for further processing.

Hope this will help some!
No one is perfect. If I have missed something or code is not working for you or if it helped you then do point out.