Created
February 3, 2017 09:05
-
-
Save davemac/6ae03a0063d2a9f907f96f4d90e3420d to your computer and use it in GitHub Desktop.
WooCommerce get parent product category ID of a product on single product page
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
global $post; | |
$terms = get_the_terms( $post->ID, 'product_cat' ); | |
foreach ( $terms as $term ) { | |
$product_cat_id = $term->term_id; | |
echo $product_cat_id; | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment