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 ); ?>
<script type="application/ld+json">
{
"@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 echo $price; ?>"
}
}
</script>
<?php }, 1000 );
Snippets: Add Brand Schema Markup to WooCommerce Products
All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)