-
-
Save mikejolley/409a5180632535addb93a2ac63576193 to your computer and use it in GitHub Desktop.
<?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; | |
} |
This seems not to work? I just tried the code, and nothing happend.
I put it my active theme's functions.php.
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.
@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.
"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.
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
This works for me, thank you!
For the sidebar widget, the other solutions did not work for me. I had to remove the category id from $args[Include]
add_filter( 'woocommerce_product_categories_widget_args', 'custom_woocommerce_remove_uncategorized_category_sidebar' );
function custom_woocommerce_remove_uncategorized_category_sidebar($args)
{
if (!empty($args['include']) && is_string($args['include']))
{
$included_categories = explode (",", $args['include']);
$uncategorized_id = array_search(get_option('default_product_cat'), $included_categories);
if ($uncategorized_id)
{
unset($included_categories[$uncategorized_id]);
$args['include'] = implode(",", $included_categories);
}
}
return $args;
}
Goes in functions.php or plugin.
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