Merge pull request #3838 from BFTrick/add-category-class-to-product-div

Adding Category & Tag Classes to Product Page
This commit is contained in:
Mike Jolley 2013-09-26 02:32:04 -07:00
commit 37d8fa3cee
1 changed files with 17 additions and 0 deletions

View File

@ -235,6 +235,23 @@ if ( ! function_exists( 'wc_product_post_class' ) ) {
if ( isset( $product->product_type ) ) {
$classes[] = "product-type-" . $product->product_type;
}
// add category slugs
$categories = wp_get_post_terms( $product->id, "product_cat" );
if ( ! empty( $categories ) ) {
foreach ($categories as $key => $value) {
$classes[] = "category-" . $value->slug;
}
}
// add tag slugs
$tags = wp_get_post_terms( $product->id, "product_tag" );
if ( ! empty( $tags ) ) {
foreach ($tags as $key => $value) {
$classes[] = "tag-" . $value->slug;
}
}
$classes[] = $product->stock_status;
}