DEV Community

Cover image for Custom tab in WooCommerce
Chris Texe
Chris Texe

Posted on

3 1

Custom tab in WooCommerce

Hello WordPress guys and gals! Sometimes when we work with WooCommerce we need to add some special tab. Recently I had to do it when I was creating a e-commerce shop for one of my client. It was a shop with clothes and every item in the shop had a size (L, M, XL etc.). So I decided to create a custom tab with "Size charts" name. In this tab I put the table with sizes.

Here you can see example but it's not from the shop I talked about above:

WooCommerce - Custom tab

So how to create a custom tab in WooCommerce?

Just open functions.php file of your theme and paste these lines of code:

/**
* Custom tab
*/
add_filter( 'woocommerce_product_tabs', 'ct_custom_tab' );
function ct_custom_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'Custom Tab', 'woocommerce' ),
'priority' => 50,
'callback' => 'ct_custom_tab_content'
);
return $tabs;
}
function ct_custom_tab_content() {
// The new tab content
echo '<h3>My Custom Tab</h3>';
echo '<p>Here\'s your new product tab!</p>';
}
view raw functions.php hosted with ❤ by GitHub

It would be great if you will comment or follow me on social media:

Chris Texe Twitter

Chris Texe LinkedIn

Also you can visit my websites:

Top comments (0)

Retry later
Retry later