Add Brand Schema Markup to WooCommerce Products
add_action( 'wp_head', function() {
// Only add brand markup on products
if ( ! is_singular( 'product' ) ) {
return;
}
// Get product price
$price = ( ( $product = wc_get_product( get_the_ID() ) ) ? $product->get_price() : false ); ?>
{
"@context": "http://schema.org/",
"@type": "Product",
"name": "Company Name",
"image": "Company img url",
"description": "Your description here",
"brand": {
"@type": "Thing",
"name": "Company Name"
},
"offers": {
"@type": "Offer",
"priceCurrency": "USD",
"price": ""
}
}
<?php }, 1000 );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)