Last active
March 5, 2018 00:47
-
-
Save ben72/8fa22744c15eb02b322d208290d68b77 to your computer and use it in GitHub Desktop.
Remove specific product categories from meta section on WooCommerce product pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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