Last active
December 25, 2022 09:48
-
-
Save mbilalsiddique1/fe2d1afbe51698b9eedba5c091ceba7c to your computer and use it in GitHub Desktop.
WooCommerce Custom Product Tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_product_tabs', 'wc_add_custom_tabs' ); | |
function wc_add_custom_tabs($tabs) { | |
// Add the custom tab | |
$tabs['specifiction_tab'] = array( | |
'title' => __('Specification', 'dcpd'), | |
'priority' => 50, | |
'callback' => 'wc_custom_tabs_cb' | |
); | |
return $tabs; | |
} | |
// we use the only callback function for all the tabs | |
function wc_custom_tabs_cb( $slug, $tab ) { | |
// display tab heading for every tab | |
echo '<h2>' . $tab[ 'title' ] . '</h2>'; | |
if ( 'specifiction_tab' === $slug ) { | |
// echo wpautop( 'Take 1 veggie capsule 1 or more times daily, with or without food.' ); | |
// you can get the tab content from product custom fields | |
echo wpautop( get_post_meta( get_the_ID(), 'suggested_use', true ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment