hide certain subcategory
-
Hi!
I have tried to hide a certain subcategory from my shop(shop page and other pages, there is a category widget).
I found that the code below works for all pages except the shop page. If i changeis_product_category()for theis_shop(), so it works for the shop page, but not for the other pages.How can i do that it works for ALL pages (shop and all others)?
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 ); function get_subcategory_terms( $terms, $taxonomies, $args ) { $new_terms = array(); // if a product category and on the shop page if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_product_category() ) { foreach ( $terms as $key => $term ) { if ( ! in_array( $term->slug, array( 'seinakellad','nastennye-chasy','wall-clock' ) ) ) { $new_terms[] = $term; } } $terms = $new_terms; } return $terms; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘hide certain subcategory’ is closed to new replies.