I would like to add aggregateRating via functions.php
This is the example code I am using:
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
$entity['aggregateRating'] = '{"@type":"AggregateRating","ratingValue":"5","bestRating":"5","worstRating":"1","ratingCount":"2"}';
return $entity;
});
It adds the code to the rich snippet, but also adds slashes to the quotation marks, so my rich snippet looks like:
"aggregateRating":"{\"@type\":\"AggregateRating\",\"ratingValue\":\"5\",\"bestRating\":\"5\",\"worstRating\":\"1\",\"ratingCount\":\"2\"}"
Is this solvable?