SHOW:
|
|
- or go back to the newest paste.
1 | - | add_filter( 'get_terms', 'remove_wc_cats', 10, 3 ); |
1 | + | function remove_wc_cats($terms, $taxonomies, $args) { |
2 | - | |
2 | + | |
3 | - | function remove_wc_cats( $terms, $taxonomies, $args ) { |
3 | + | $new_terms = array(); |
4 | - | |
4 | + | |
5 | - | $new_terms = array(); |
5 | + | // Si es una categoría de producto, la tienda o la página de inicio. |
6 | - | |
6 | + | if (in_array('product_cat', $taxonomies) && !is_admin() && is_shop() || is_front_page()) { |
7 | - | // if it is a product category and on the shop page |
7 | + | |
8 | - | if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() || is_front_page()) { |
8 | + | foreach ($terms as $key => $term) { |
9 | - | |
9 | + | |
10 | - | foreach ( $terms as $key => $term ) { |
10 | + | if (!in_array($term->slug, array('categoria-1', 'categoria-2'))) { // Slugs de las categorias a quitar |
11 | - | |
11 | + | $new_terms[] = $term; |
12 | - | if ( ! in_array( $term->slug, array( 'sin-categorizar','acompanamientos' ) ) ) { //slugs de las categorias a remover |
12 | + | } |
13 | - | $new_terms[] = $term; |
13 | + | } |
14 | - | } |
14 | + | $terms = $new_terms; |
15 | - | } |
15 | + | } |
16 | - | $terms = $new_terms; |
16 | + | |
17 | - | } |
17 | + | return $terms; |
18 | - | |
18 | + | } |
19 | - | return $terms; |
19 | + | add_filter('get_terms', 'remove_wc_cats', 10, 3); |