Created
May 30, 2014 15:32
-
-
Save krmd/e617d21a289a8e5fcda1 to your computer and use it in GitHub Desktop.
WooCommerce: Add Category class to body tag
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
// add taxonomy term of products category to body classes | |
function woo_custom_taxonomy_in_body_class( $classes ){ | |
if( is_singular( 'product' ) ) | |
{ | |
$custom_terms = get_the_terms(0, 'product_cat'); | |
if ($custom_terms) { | |
foreach ($custom_terms as $custom_term) { | |
$classes[] = 'product_cat_' . $custom_term->slug; | |
} | |
} | |
} | |
return $classes; | |
} | |
add_filter( 'body_class', 'woo_custom_taxonomy_in_body_class' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment