0
나는 계층 적 사용자 정의 세금 (woocom 제품)을 보유하고 있으며 일부 빵 부스러기를 빌드하려고합니다. 나는 get_ancestors()
을 발견했고, 용어를 사용하려고 생각하고있다. 그러나 내가 제품에 도착하면 나는 길을 잃는다. 그것이 속한 즉각적인 최상위 범주 (즉, 제품 목록)를 얻는 방법? 여기 WooCommerce 제품의 상위 부모 카테고리를 가져 오는 방법은 무엇입니까?
All Categories **term ID 192**
-Sub Cat One **term id 204**
-- Sub Cat Two (products listed out here) **term id 207**
--- Product
당신은 탐색 경로를 구축하기 위해이 코드를 사용할 수 있습니다
function build_breadcrumbs($product_cat_id, $type) {
if('product' === $type) {
$terms = get_the_terms($product_cat_id, 'product_cat');
error_log(print_r( $terms, true));
}
else {
$ancestors = get_ancestors($product_cat_id, $type);
error_log(print_r( $ancestors, true));
}
}