M
M
MisTFoR2021-02-08 18:59:30
WooCommerce
MisTFoR, 2021-02-08 18:59:30

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

2 answer(s)
E
Elio Don, 2021-02-14
@elmurzaalchakov

What's the problem with just not adding it to the menu?

P
pepelnyy, 2021-07-26
@pepelnyy

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;
}

  //  спрятали

Stole somewhere, I don't remember where.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question