-
Hello,
i am using stamped review plugin and rank math is overwriting their review rich snippet. They say it can be solved if this code is added to rankmath. Could you do it in the next update.
The rich snippets can be installed and integrated with Rankmath’s using the following codes:
<script>
function addEventListenerStamped(el, eventName, handler) {
if (el.addEventListener) { el.addEventListener(eventName, handler); }
else { el.attachEvent(‘on’ + eventName, function () { handler.call(el); }); }}
addEventListenerStamped(document, ‘stamped:reviews:loaded’, function(e) {
var ratingCount = jQueryStamped(‘meta[itemprop=”reviewCount”]’).attr(‘content’);
var ratingValue = jQueryStamped(‘meta[itemprop=”ratingValue”]’).attr(‘content’);var richSnippet = {
“@context”: “http://schema.org”,
“@type”: “Product”,
“@id”: “https://STORE.COM/URL/#product”
}if (parseInt(ratingValue) > 0){
richSnippet.aggregateRating = {
“@type”: “AggregateRating”,
“ratingValue”: ratingValue,
“reviewCount”: ratingCount
}
}
var script = document.createElement(‘script’);
script.type = ‘application/ld+json’;
script.innerHTML = JSON.stringify(richSnippet);
document.getElementsByTagName(‘head’)[0].appendChild(script);
});
</script>Kindly note that you will need to include the property “@id” in Rankmath’s code to match Stamped.io’s schema codes, in order for the aggregateRating to register
The ticket ‘Stamped Review’ is closed to new replies.