Forked from technoknol/Woocommerce get product category list .php
Created
September 6, 2019 14:21
-
-
Save hemusyl/a56290ba69c02f046a9c0d0ae14e825c to your computer and use it in GitHub Desktop.
Woocommerce get product category list
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 | |
global $post; | |
$terms = get_the_terms( $post->ID, 'product_cat' ); | |
foreach ($terms as $term) { | |
$product_cat_id[] = $term->term_id; | |
break; | |
} | |
print_r (array_filter( array_unique( $product_cat_id ))) ; | |
## Please look into the meta.php file in the “templates/single-product/” folder of the WooCommerce plugin. | |
echo $product->get_categories( ', ', '<span>' . _n( 'Category:', 'Categories:', sizeof( get_the_terms( $post->ID, 'product_cat' ) ), 'woocommerce' ) . ' ', '.</span>' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment