Hello,
Please add the below code in the active theme functions.php file
these codes hide particular categories from the shop page. if you want to hide all categories then please add all categories id.
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
$hide_category = array( 126 ); // Ids of the category you don't want to display on the shop page
// if a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() )
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->term_id, $hide_category ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
if you want to hide categories in product page then please add the below code in the active theme functions.php file
/* Remove Categories from Single Products */
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_meta', 40 );
or you can also hide categories using css in product page.
.product_meta .posted_in {display: none !important;}
I hope it will help you