# Add the Brand to Product Structured Data

> Includes the product brand in the product schema WooCommerce outputs, which Google uses for rich results and Merchant listings.

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

## Code

```php
add_filter( 'woocommerce_structured_data_product', function ( $markup, $product ) {
    $default_brand = get_bloginfo( 'name' ); // Used when the product has no brand.

    if ( ! empty( $markup['brand'] ) ) {
        return $markup;
    }

    $brand = '';

    if ( taxonomy_exists( 'product_brand' ) ) {
        $terms = get_the_terms( $product->get_id(), 'product_brand' );

        if ( $terms && ! is_wp_error( $terms ) ) {
            $brand = $terms[0]->name;
        }
    }

    $brand = $brand ? $brand : $default_brand;

    if ( $brand ) {
        $markup['brand'] = array(
            '@type' => 'Brand',
            'name'  => wp_strip_all_tags( $brand ),
        );
    }

    return $markup;
}, 10, 2 );
```

## Notes

Uses the WooCommerce Brands taxonomy when it exists, otherwise falls back to $default_brand.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add the Brand to Product Structured Data" 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/
