您好,我想开发一个woo-commerce网站和JSON API,我想“获取产品的所有类别”
<?php
$terms = get_the_terms( '1753', 'product_cat' );
//$nterms = get_the_terms( '1753', 'product_tag' );
foreach( $terms as $term ) {
$product_cat_id = $term->term_id;
$product_cat_name = $term->name;
break;
}
答案 0 :(得分:0)
请尝试:
<?php
get_the_term_list( '1753', 'product_cat', '', ', ', '' ); ?>
在此处检查参考: https://codex.wordpress.org/Function_Reference/get_the_term_list