Skip to content

Instantly share code, notes, and snippets.

@mbilalsiddique1
Last active December 25, 2022 09:48
Show Gist options
  • Save mbilalsiddique1/fe2d1afbe51698b9eedba5c091ceba7c to your computer and use it in GitHub Desktop.
Save mbilalsiddique1/fe2d1afbe51698b9eedba5c091ceba7c to your computer and use it in GitHub Desktop.
WooCommerce Custom Product Tabs
<?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