Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce 3.3 - Hide uncategorized category from the shop page on the frontend
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'woocommerce_product_subcategories_args', 'custom_woocommerce_product_subcategories_args' );
function custom_woocommerce_product_subcategories_args( $args ) {
$args['exclude'] = get_option( 'default_product_cat' );
return $args;
}
@keeslamper

This comment has been minimized.

Copy link

keeslamper commented Feb 15, 2018

Is this also for sidebar widget categories? Looks like it's not working.

@kb6673

This comment has been minimized.

Copy link

kb6673 commented Feb 20, 2018

To apply this on the widget, add this next to the existing add_filter

add_filter( 'woocommerce_product_categories_widget_args', 'remove_uncategorized_category' );

@Babelfisch

This comment has been minimized.

Copy link

Babelfisch commented Feb 26, 2018

remove_uncategorized_category kills the sidebar menu completely.

@richardkuipers

This comment has been minimized.

Copy link

richardkuipers commented Feb 27, 2018

For sidebar try:

add_filter( 'woocommerce_product_categories_widget_args', 'custom_woocommerce_product_subcategories_args' );

function custom_woocommerce_product_subcategories_args( $args ) {

$args['exclude'] = get_option( 'default_product_cat' );

return $args;

}

works for me

@JayHoltslander

This comment has been minimized.

Copy link

JayHoltslander commented Mar 7, 2018

@richardkuipers I put that code in a site's functions.php but the Uncategorized category is still in the shop's sidebar.

@kieranbarnes I also tried your code and it too didn't work for me.

This method ended up working for me.

@ghost

This comment has been minimized.

Copy link

ghost commented Mar 8, 2018

Are we supposed to be modifying the code you have or simply copy and pasting it? When I add this to my staging site uncategorized does not go away. Why was this even introduced? This should be a basic setting in woocommerce to turn off and not be forced on.

@glorious1

This comment has been minimized.

Copy link

glorious1 commented Mar 10, 2018

The Uncategorized category shows in my website as an option in the category dropdown for vendors.

  • The category is empty.
  • The code above did not work.
  • Neither did the css solution.

Unfortunately you would not be able to see that page unless you first registered to become a member and then a vendor. Mike if you're interested I could set up such an account for you so you can see it.

@SeanGreen1992

This comment has been minimized.

Copy link

SeanGreen1992 commented Apr 25, 2018

I just edited the category name in Product Categories to: & emsp; (Dont leave a space between & emps; - If I write it correctly it dissapears. If that's not proof that this works I don't know what is)

This hides the uncategorized listing in the Woocommerce shop menu

@boutzamat

This comment has been minimized.

Copy link

boutzamat commented May 8, 2018

This seems not to work? I just tried the code, and nothing happend.
I put it my active theme's functions.php.

@BlackWireKevin

This comment has been minimized.

Copy link

BlackWireKevin commented May 17, 2018

This is extremely frustrating. I dont understand why this was forced in the first place. Nearly every business will load a product, test it and view it and make sure it looks correct then push it into a category to be seen by the customers. Additionally some have special items only available by a direct link. The WC update really needed this to be an option. There is zero logic in this being forced on everyone. Not one of the snippets or css codes I have found work.

My next step is simply delete this from the database and see how that works out. It is sad that woocommerce seems to be getting better and better then they do something like this to completely mess up a website and its flow.

@andrewmclagan

This comment has been minimized.

Copy link

andrewmclagan commented Jul 12, 2018

@BlackWireKevin Welcome to open-source software. As you are clearly a non-developer you'd be better served placing your funds into someone who has devoted those years of their lives to obtaining those skills rather then venting your frustrations with those who are - in essence - giving you thousands of hours of their time so you can run your business. Your attitude in the face of such gratitude is pretty poor.

So I think you should: skill up - shut up - OR pay up.

@dzeriho

This comment has been minimized.

Copy link

dzeriho commented Aug 12, 2018

"Hide uncategorized category from the shop page on the frontend" - this is more like "Hide default category from the shop page on the frontend", so it's kind of not doing its thing, and can be quite harmful if you use other category as your default category. Remove this file please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.