Created
February 27, 2017 19:13
-
-
Save cristacheda/3a5c8f09f031e0c1b420be9352a0c247 to your computer and use it in GitHub Desktop.
woocommerce if product is in category
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
//Check category | |
global $post; | |
$terms = wp_get_post_terms( $post->ID, 'product_cat' ); | |
foreach ( $terms as $term ) $categories[] = $term->slug; | |
if ( in_array( 'sacouri', $categories ) ) { | |
echo "<div style='display: none;'>sacouri</div>"; | |
} elseif ( in_array( 'camasi', $categories ) ) { | |
echo "<div style='display: none;'>camasi</div>"; | |
} elseif ( in_array( 'pantofi', $categories ) ) { | |
echo "<div style='display: none;'>pantofi</div>"; | |
} else { | |
echo "<div style='display: none;'>nocat</div>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment