0

I have created a custom tab and it currently displays on all products. I would like to only show the tab on products in a certain category or subcategory. I have tried several options, all result in "There has been a critical error on your website."

I currently only have products in sub-categories, not their parent category.

//Add custom product data tab
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {

    global $product;

    $tabs['test_tab'] = array(
        'title'     => __( 'Sizing guidelines', 'woocommerce' ),
        'priority'  => 25,
        'callback'  => 'woo_new_product_tab_content'
    );
    return $tabs;
}


//The new tab content
function woo_new_product_tab_content() {

    echo '<h2>Sizing Guidelines</h2>';
    echo '<img src="image"/>';
}

All help appreciated. I don't have much experience with PHP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.