我已通过此功能从Woocommerce获取所有父类别
$terms = get_terms( array(
\'taxonomy\' => \'product_cat\',
\'hide_empty\' => false,
\'parent\' => 0
) );
但我还没有做到这一点WP_Query. 现在我有两个问题:如何使用WQ\\u Query从WooCommerce获取类别列表?建议使用WP\\u Query over get\\u terms
我已通过此功能从Woocommerce获取所有父类别
$terms = get_terms( array(
\'taxonomy\' => \'product_cat\',
\'hide_empty\' => false,
\'parent\' => 0
) );
但我还没有做到这一点WP_Query. 现在我有两个问题:如何使用WQ\\u Query从WooCommerce获取类别列表?建议使用WP\\u Query over get\\u terms
$category_detail=get_the_category(get_the_ID());//$post->ID
foreach($category_detail as $cd)
{
$name_cat=$cd->cat_name;
$id_cat=$cd->term_id;
}
try now this code
为什么get_terms() 是否按要求返回最多10个结果?我很困惑。 $args = array( \'taxonomy\' => \'video_tag\', \'parent\' => 0, \'number\' => 10 ); error_log(\"JPH get_terms args: