Cannot redeclare function get_subcategory_terms
-
Hi so this is my php code to hide a specific category in my woocommerce shop page, however when I enter it into codesnippet plugin, it cannot activate, it kept showing the message
“Cannot redeclare function get_subcategory_terms“
Can someone please help, thank you!
/**Show products only of selected category**/
function get_subcategory_terms( $terms, $taxonomies, $args ) { $new_terms = array();
$hide_category = array( 48 ); // 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;
}
- The topic ‘Cannot redeclare function get_subcategory_terms’ is closed to new replies.