douyuliu9527 2019-07-12 13:38
浏览 380

如何获得Woocommerce产品的所有类别

hello I want to develop a woo-commerce website and JSON API, I want to "get all categories for a product"

<?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;
}
  • 写回答

1条回答 默认 最新

  • dpxnrx11199 2019-07-12 14:26
    关注

    Please try:

    <?php
    get_the_term_list( '1753', 'product_cat', '', ', ', '' ); ?> 
    

    Check reference here: https://codex.wordpress.org/Function_Reference/get_the_term_list

    评论

报告相同问题?

悬赏问题

  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000