twoeight
6/29/2014 - 10:07 AM

body class Aggiungere la tassonomia woocommerce!

Aggiungere la tassonomia woocommerce alla body class!

<?php
 
// add woocommerce taxoonomy term to body_class
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' );
 
?>