# Shared Product Tab for One Category

> Adds the same extra tab, such as "Care instructions" for clothing or "Allergens" for food, to every product in the categories you choose.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, product-tabs, categories
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-category-product-tab/

## Code

```php
$wpide_cat_tab = array(
    'categories' => array( 'clothing' ),                                                     // Category slugs.
    'title'      => 'Care instructions',
    'content'    => '<p>Machine wash at 30°C. Do not tumble dry. Iron on a low heat inside out.</p>',
    'priority'   => 30,
);

add_filter( 'woocommerce_product_tabs', function ( $tabs ) use ( $wpide_cat_tab ) {
    global $product;

    if ( $product instanceof WC_Product && has_term( $wpide_cat_tab['categories'], 'product_cat', $product->get_id() ) ) {
        $tabs['wpide_cat_tab'] = array(
            'title'    => $wpide_cat_tab['title'],
            'priority' => $wpide_cat_tab['priority'],
            'callback' => function () use ( $wpide_cat_tab ) {
                echo wp_kses_post( do_shortcode( $wpide_cat_tab['content'] ) );
            },
        );
    }

    return $tabs;
} );
```

## Notes

Edit the content here once and every product in the categories updates; shortcodes are run.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Shared Product Tab for One Category" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
