Skip to content

Instantly share code, notes, and snippets.

@ben72
Last active March 5, 2018 00:47
Show Gist options
  • Save ben72/8fa22744c15eb02b322d208290d68b77 to your computer and use it in GitHub Desktop.
Save ben72/8fa22744c15eb02b322d208290d68b77 to your computer and use it in GitHub Desktop.
Remove specific product categories from meta section on WooCommerce product pages
/* Remove specific product categories from meta section on WooCommerce product pages */
add_filter('get_the_terms', 'exclude_specific_product_categories', 10, 3);
function exclude_specific_product_categories($terms) {
if(is_product()) {
$exclude_categories = array('Ekologiska julklappar', 'Ekologiska juklappar herr', 'Ekologiska juklappar dam', 'Ekologiska juklappar barn'); // Replace with any product categories you want to remove!
foreach($terms as $term_index => $term_object) {
if(in_array($term_object->name, $exclude_categories)) {
unset($terms[$term_index]);
}
}
}
return $terms;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment