# Product Subtitle Field

> Adds a subtitle field to products and shows it under the product name on product pages and in shop listings, for taglines like "Organic cotton, made in Portugal".

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

## Code

```php
$wpide_subtitle_in_loop = true; // Also show in shop listings.

add_action( 'woocommerce_product_options_general_product_data', function () {
    global $product_object;

    woocommerce_wp_text_input( array(
        'id'    => '_wpide_subtitle',
        'label' => 'Subtitle',
        'value' => $product_object instanceof WC_Product ? $product_object->get_meta( '_wpide_subtitle' ) : '',
    ) );
} );

add_action( 'woocommerce_admin_process_product_object', function ( $product ) {
    // phpcs:ignore WordPress.Security.NonceVerification -- WooCommerce verifies the product save nonce.
    if ( isset( $_POST['_wpide_subtitle'] ) ) {
        $product->update_meta_data( '_wpide_subtitle', sanitize_text_field( wp_unslash( $_POST['_wpide_subtitle'] ) ) );
    }
} );

$wpide_subtitle_html = function ( $tag ) {
    return function () use ( $tag ) {
        global $product;

        $subtitle = $product instanceof WC_Product ? $product->get_meta( '_wpide_subtitle' ) : '';

        if ( '' !== $subtitle ) {
            printf( '<%1$s class="wpide-subtitle">%2$s</%1$s>', tag_escape( $tag ), esc_html( $subtitle ) );
        }
    };
};

add_action( 'woocommerce_single_product_summary', $wpide_subtitle_html( 'p' ), 6 );

if ( $wpide_subtitle_in_loop ) {
    add_action( 'woocommerce_after_shop_loop_item_title', $wpide_subtitle_html( 'span' ), 4 );
}
```

## Notes

Set $wpide_subtitle_in_loop to false to show it on product pages only.

## How to use it

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