Monday, September 19, 2022
HomeWordPress Developmentphp - Disguise little one of mum or dad classes already hidden...

php – Disguise little one of mum or dad classes already hidden with “get_terms_args” – Woocommerce


I would wish your assist as I’m unable to cover subcategories, or slightly, little one classes of already hidden and outlined classes.
I attempted getting into $args['parent'] = 0; but it surely hides all of the mum or dad classes. I’ve additionally tried $args['exclude_tree'], however with this warning “Allowed reminiscence dimension of 268435456 bytes exhausted (tried to allocate 20480 bytes)” then attempt to improve the reminiscence restrict in your config file.
I might be grateful if somebody may assist me out.

That is the perform:

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

/**
* Exclude product classes from Woocommerce
*/

perform 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 need to exclude
$args['parent'] = 0;
return $args;
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments