0

I would need your help as I am unable to hide subcategories, or rather, child categories of already hidden and defined categories. I tried entering $args['parent'] = 0; but it hides all the parent categories. I've also tried $args['exclude_tree'], but with this warning "Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes)" then try to increase the memory limit in your config file. I would be grateful if someone could help me out.

This is the function:

add_filter( 'get_terms_args', 'mamaduka_edit_get_terms_args', 10, 2 );

/**
* Exclude product categories from Woocommerce
*/

function mamaduka_edit_get_terms_args( $args, $taxonomies ) {
 //print_r($taxonomies);
 //print_r($args);
if ( is_admin() && 'product_cat' !== $taxonomies )
    return $args;

$args['exclude'] = [50, 22, 20, 31, 35, 45, 40, 65, 37, 40, 3434]; // Array of cat ids you want to exclude
$args['parent'] = 0;
return $args;
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy