# Custom Product Tab Edited per Product

> Adds an editor box to each product for an extra tab, such as "Ingredients" or "Specifications", that only appears on products where you filled it in.

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

## Code

```php
$wpide_field_tab = array(
    'title'    => 'Specifications', // Tab title.
    'priority' => 25,               // Position among the tabs.
);

add_action( 'add_meta_boxes_product', function () use ( $wpide_field_tab ) {
    add_meta_box( 'wpide-tab-content', $wpide_field_tab['title'] . ' tab', function ( $post ) {
        wp_nonce_field( 'wpide_tab_content', 'wpide_tab_content_nonce' );
        wp_editor( get_post_meta( $post->ID, '_wpide_tab_content', true ), 'wpide_tab_content', array( 'textarea_rows' => 8, 'media_buttons' => false ) );
    }, 'product', 'normal' );
} );

add_action( 'save_post_product', function ( $post_id ) {
    if ( ! isset( $_POST['wpide_tab_content_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['wpide_tab_content_nonce'] ), 'wpide_tab_content' ) || ! current_user_can( 'edit_post', $post_id ) || wp_is_post_autosave( $post_id ) ) {
        return;
    }

    update_post_meta( $post_id, '_wpide_tab_content', wp_kses_post( wp_unslash( $_POST['wpide_tab_content'] ?? '' ) ) );
} );

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

    $content = $product instanceof WC_Product ? get_post_meta( $product->get_id(), '_wpide_tab_content', true ) : '';

    if ( '' !== trim( (string) $content ) ) {
        $tabs['wpide_field_tab'] = array(
            'title'    => $wpide_field_tab['title'],
            'priority' => $wpide_field_tab['priority'],
            'callback' => function () use ( $content ) {
                echo wp_kses_post( wpautop( do_shortcode( $content ) ) );
            },
        );
    }

    return $tabs;
} );
```

## Notes

Change the tab title in $wpide_field_tab; the content allows post HTML and runs shortcodes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Custom Product Tab Edited per Product" 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/
