Skip to content

Instantly share code, notes, and snippets.

@yuliyang
Created October 7, 2022 13:47
Show Gist options
  • Save yuliyang/7ef9b13a3404612750ae630fd448667a to your computer and use it in GitHub Desktop.
Save yuliyang/7ef9b13a3404612750ae630fd448667a to your computer and use it in GitHub Desktop.
[ WooCommerce ] Single Product - add new/rename product info tab
<?php
// single product - add new tab
add_filter( 'woocommerce_product_tabs', 'dejavu_woo_new_tab' );
function dejavu_woo_new_tab( $tabs ) {
// rename default product tabs
$tabs[ 'description' ][ 'title' ] = '內容簡介';
$tabs[ 'additional_information' ][ 'title' ] = '其他資訊';
// display only when ACF custom fields is presented
if( is_singular('product') && get_field('my-field') ) :
$tabs['other_tabs'] = array(
'title' => __( '目錄', 'woocommerce' ),
'priority' => 1,
'callback' => 'dejavu_woo_new_tab_content'
);
endif;
return $tabs;
}
function dejavu_woo_new_tab_content() {
echo $variable = get_field('my-field');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment