Created
December 1, 2020 20:41
-
-
Save tradesouthwest/6a02060cb18768b433802aee34f75950 to your computer and use it in GitHub Desktop.
Check if single product has a specific product category.
This file contains 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
<?php | |
// checking terms since wc_product are not post terms | |
function product_cat_contingencies() | |
{ | |
global $post; | |
// get the product category term objects | |
$terms = wp_get_post_terms( $post->ID, 'product_cat' ); | |
foreach ( $terms as $term ) $categories[] = $term->slug; | |
if( in_array('custom-tarps', $categories) ) { | |
return true; | |
} else { | |
return false; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment