简体   繁体   中英

How to create a new Woocommerce product tab?

I need to create a new product tab called Category and Tags

Could you tell me how to do it without using plugins?

preview:

在此输入图像描述

Add this code to your function.php file, it will create another tab and now you can do what ever, in that callback function.

add_filter( 'woocommerce_product_tabs', 'woo_cat_product_tab' );
function woo_cat_product_tab( $tabs ) {

    // Adds the new tab

    $tabs['tag_cat_tab'] = array(
        'title'     => __( 'Tag and Category', 'woocommerce' ),
        'priority'  => 50,
        'callback'  => 'woo_cat_product_tab_content'
    );

    return $tabs;

}
function woo_cat_product_tab_content() {

    // The new tab content
    global $product;
    $id = $product->id;
    //Your code

}

for more details check WooCommerce docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM