Answer the question
In order to leave comments, you need to log in
How to hide a category from the entire site?
The code given below:
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->slug, array( 'stands', 'lkmstands',', ) ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
Answer the question
In order to leave comments, you need to log in
To filter the term query, use the filterpre_get_terms
function wc_custom_sort_get_terms_args( $args, $taxonomies ) {
if ( isset( $taxonomies[ 'product_cat' ] ) ) {
$args['exclude'] = [5,6,7];
}
return $args;
}
add_filter( 'get_terms_args', 'wc_custom_sort_get_terms_args', 10, 2 );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question