第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從當前父類別中獲取 Woocommerce 所有子類別

如何從當前父類別中獲取 Woocommerce 所有子類別

PHP
哈士奇WWW 2021-06-30 18:57:44
我希望當我點擊它們時,我在一個頁面上有一些產(chǎn)品類別,然后我應該得到她孩子的類別。我希望這項工作應該在單頁上完成,而不是多頁 我該如何做這項工作
查看完整描述

2 回答

?
米琪卡哇伊

TA貢獻1998條經(jīng)驗 獲得超6個贊

您可以使用get_term_children()來自產(chǎn)品類別術語 Id 的WordPress 專用功能:

$child_terms_ids = get_term_children( $term_id, 'product_cat' );

它返回一組子項 Id。


對于產(chǎn)品類別存檔頁面,您可以使用:


// get the current product category term ID

if ( is_product_category() ) {

    $term_id = (int) get_queried_object_id();

}


if ( term_exists( $term_id, 'product_cat' ) ) {

    $child_terms_ids = get_term_children( $term_id, 'product_cat' );


    // Loop through child terms Ids

    foreach ( $child_terms_ids as $child_term_id ) {

        $child_term = get_term_by( 'term_id', $child_term_id, 'product_cat' );

        // The term name

        $child_name = $child_term->name;

        // The term link

        $child_link = get_term_link( $child_term, 'product_cat' );

    }

}


查看完整回答
反對 回復 2021-07-02
  • 2 回答
  • 0 關注
  • 249 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號