-
I’m using this code to set brand fields dynamically:
/** * Filter to add custom Brand for WooCommerce Products. */ add_filter('rank_math/snippet/rich_snippet_product_entity', function( $entity ) { if (strpos(get_the_title( $post_id ),'Zippo') !== false) { $entity['brand'] = 'Zippo'; } elseif (strpos(get_the_title( $post_id ),"Casio") !== false) { $entity['brand'] = 'Casio'; } elseif (strpos(get_the_title( $post_id ),"Q&Q") !== false) { $entity['brand'] = 'Q&Q'; } elseif (strpos(get_the_title( $post_id ),"Seiko") !== false) { $entity['brand'] = 'Seiko'; } elseif (strpos(get_the_title( $post_id ),"Citizen") !== false) { $entity['brand'] = 'Citizen'; } elseif (strpos(get_the_title( $post_id ),"Parker") !== false) { $entity['brand'] = 'Parker'; } elseif (strpos(get_the_title( $post_id ),"Blitz") !== false) { $entity['brand'] = 'Blitz'; } elseif (strpos(get_the_title( $post_id ),"Connoisseurs") !== false) { $entity['brand'] = 'Connoisseurs'; } elseif (strpos(get_the_title( $post_id ),"Li-Li") !== false) { $entity['brand'] = 'Aros Abridores Li-Li'; } elseif (strpos(get_the_title( $post_id ),"CH") !== false) { $entity['brand'] = 'CH Aros Abridores'; } elseif (strpos(get_the_title( $post_id ),"Spotify") !== false) { $entity['brand'] = 'Spotify'; } else { $entity['brand'] = 'Joyeria GyA'; } return $entity; } );It’s a variation of the code that I found of your forum as a fix for custom brand:
/** * Filter to add custom Brand for WooCommerce Products. */ add_filter('rank_math/snippet/rich_snippet_product_entity', function( $entity ) { $entity['brand'] = 'Rank Math'; return $entity; } );But the code is getting and error in Google search console: The object type of the “brand” field is not valid. I search in the code of the page and its setting the brand type as thing and not as a brand.
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
The ticket ‘The object type of the “brand” field is not valid’ is closed to new replies.