Answer the question
In order to leave comments, you need to log in
What is the plugin to show/hide woocommerce categories?
Suggest a plugin to show/hide woocommerce categories.
Thanks
Answer the question
In order to leave comments, you need to log in
Maybe there is a plugin, but I did not find it, but did it as follows:
I needed to hide the "Options" category (and its subcategories) -
in functions.php I write:
// прячем опции
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// если находится в товарной категории и на странице магазина, 'options' - это slug категории, которую надо скрыть
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->slug, array( 'options' ) ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
// спрятали
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question