How to add a custom product tab in WooCommerce
WooCommerce product pages come with three tabs: Description, Additional information and Reviews. To add your own, like “Care instructions” or “Size guide”, you can write a short PHP snippet or use a plugin. This guide shows both, with code you can copy.
How WooCommerce builds product tabs
Every tab on a single product page comes from one filter, woocommerce_product_tabs. It receives an array of tabs keyed by an ID, and each tab has three parts:
- title: the label on the tab.
- priority: the sort order, lowest first. Description is 10, Additional information 20 and Reviews 30.
- callback: the function that prints the tab’s content. WooCommerce passes it the tab’s key and the tab array.
WooCommerce leaves out tabs with nothing to show: Additional information only appears when a product has visible attributes, weight or dimensions, and Reviews only when reviews are enabled. Classic themes like Storefront print the tabs from this filter, and in block themes the Product Details block does too, so the same code works in both.
The code way
Add PHP to your store in one of two places, never in the parent theme’s functions.php, which is replaced on every theme update:
- your child theme’s
functions.php, or - a snippets plugin such as Code Snippets, which runs PHP from the dashboard. Paste the code without the opening
<?phptag.
Test on a staging copy first: a PHP syntax error in functions.php can take the site down until you fix the file.
A tab with the same text on every product
The simplest case is a fixed tab, for example a short shipping policy:
add_filter( 'woocommerce_product_tabs', 'mystore_add_shipping_tab', 98 );
function mystore_add_shipping_tab( $tabs ) {
$tabs['shipping'] = array(
'title' => __( 'Shipping & returns', 'mystore' ),
'priority' => 25,
'callback' => 'mystore_shipping_tab_content',
);
return $tabs;
}
function mystore_shipping_tab_content( $key, $tab ) {
printf( '<h2>%s</h2>', esc_html( $tab['title'] ) );
echo wp_kses_post( wpautop(
"We ship within 2 business days.\n\nReturns are free within 30 days of delivery."
) );
}
Priority 25 puts the tab between Additional information and Reviews. The printf line adds a heading inside the panel, the way WooCommerce’s Description tab does; delete it if you don’t want one. Rename the mystore_ prefix and the mystore text domain to something unique to your site.
A tab with different text per product
Most custom tabs hold product-specific content. The lightest way to store it without another plugin is a custom field:
- In the product editor, open Screen Options at the top right and tick Custom Fields.
- In the Custom Fields box below the editor, add a field named
care_instructionswith this product’s text. - Add the snippet below.
add_filter( 'woocommerce_product_tabs', 'mystore_add_care_tab', 98 );
function mystore_add_care_tab( $tabs ) {
global $product;
if ( ! $product instanceof WC_Product ) {
return $tabs;
}
$care = (string) $product->get_meta( 'care_instructions' );
if ( '' === trim( $care ) ) {
return $tabs; // No text, no tab.
}
$tabs['care'] = array(
'title' => __( 'Care instructions', 'mystore' ),
'priority' => 25,
'callback' => 'mystore_care_tab_content',
);
return $tabs;
}
function mystore_care_tab_content( $key, $tab ) {
global $product;
printf( '<h2>%s</h2>', esc_html( $tab['title'] ) );
echo wp_kses_post( wpautop( (string) $product->get_meta( 'care_instructions' ) ) );
}
The tab appears only on products with text in the field, so there are no empty tabs. wp_kses_post() keeps safe HTML such as links, lists and bold text and strips scripts; wpautop() turns line breaks into paragraphs; the title goes through esc_html().
Where the code way falls short
- Editing is raw. The Custom Fields box is a plain textarea: no formatting toolbar, no media button, no preview.
- Every tab is another snippet. A size guide, a warranty and an ingredients tab means three fields and three pairs of functions to maintain.
- Shortcodes and embeds don’t run unless you add
do_shortcode()or WordPress’s embed handler yourself. - Text shared by many products has to be copied into each product’s field, or hard-coded.
For one fixed tab on a store maintained by a developer, a snippet is fine. For tabs that you or your team edit often, a plugin is easier.
The plugin way: Tabwright (free)
Tabwright is our product tabs plugin. It uses the same woocommerce_product_tabs filter, so it works with the same themes, and gives every product a tab editor:
- Install and activate Tabwright. WooCommerce must be active.
- Edit a product and open Product data → Product tabs.
- Click Add custom tab, enter a title and write the content in the WordPress editor: formatting, media, links, shortcodes and embeds all work.
- Use the arrows to reorder the product’s tabs, then click Update.
For text you reuse, such as shipping or warranty terms, create a saved tab under WooCommerce → Product Tabs and add it to products with Add saved tab. Edit it once and every product that uses it updates. Under Default tabs you choose where custom tabs sit relative to Description, Additional information and Reviews.
All of this is in the free plugin, with no limit on tabs or products, and the free plugin makes no external requests. Tabwright Pro is a paid add-on for extra tab types (FAQ, video, downloads) and rules that show a saved tab automatically by category, tag or stock status. You don’t need it to add custom tabs.
One limitation: Tabwright’s panel lives in the classic product editor, which is WooCommerce’s default. It doesn’t support the new product block editor yet.
FAQ
Where should I put the snippet?
In a child theme’s functions.php or in a snippets plugin such as Code Snippets. Code in a parent theme’s functions.php is lost when the theme updates.
Can I show a custom tab on only some products?
Yes. In code, return the tabs unchanged when your condition isn’t met, as the custom field example does. In Tabwright, a tab shows only on the products you add it to; Tabwright Pro can also show a saved tab automatically by category, tag, product type or stock status.
Do custom tabs work with block themes?
Yes, as long as the single product template uses WooCommerce’s product tabs. In block themes the Product Details block prints the tabs from the same woocommerce_product_tabs filter, so snippets and Tabwright work there too.