Hi Gilles,
Yes, that is the only code you should add.
Hello
Added the code and it is showing the reviews no in the structured data testing tool. See: https://search.google.com/structured-data/testing-tool?hl=nl#url=https%3A%2F%2Fplanted-box.com%2Fproduct%2Fall-in-one%2F
However, “itemreviewed” is still missing. Is it possible to add this too?
I’m also getting several other warnings in the data testing tool but I do not believe this has anything to do with the reviews but rather Woocommerce and Rankmath?
Hello,
The Rank Math plugin reads the value from the reviews and ratings which users give using the comment form on the product pages. If a user has added any reviews then it will show in the Schema Markup.
I see Google Structured data testing tool is throwing warnings in the isRealated, isSimilar fields in Product schema but it’s a false positive. In isRelatedTo and isSimilar only product name and URL are required. You can check this in the new Google Rich Snippet testing tool: https://search.google.com/test/rich-results
If you don’t want to show isRelated & isSimilar fields in the schema then please replace the code we provided you before with the following:
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
global $post;
$entity['@id'] = get_the_permalink( $post );
if ( isset( $entity['isRelatedTo'] ) ) {
unset( $entity['isRelatedTo'] );
}
if ( isset( $entity['isSimilarTo'] ) ) {
unset( $entity['isSimilarTo'] );
}
return $entity;
});
I hope that helps. Thank you.
Hi
Thank you, that worked!
I also want to add “Brand” to my structured data. What code should I use for this? I only sell my own branded products so this would be my brand name for everything.
PS: I think it’s amazing I get this level of support for a free product while I got shitty support for a paid SEO plugin in the past. Definitely subscribing to Rankmath Pro when it arrives! 🙂
Hi Gilles,
We are so glad to be of help.
You can use this code for adding a brand name:
// Add Brand for Products.
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
$entity['brand'] = 'Rank Math';
return $entity;
});
Change “Rank Math” to your own brand name.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.