-
Hello, I’m currently using Rank Math’s Product Schema.
The schema functions as expected, but I’ve encountered an issue with the missing aggregateRating and Review schema that Google Search Console has flagged. To address this, I created the following code:
add_filter( 'woocommerce_structured_data_product', 'custom_product_structured_data', 10, 2 ); function custom_product_structured_data( $markup, $product ) { if ( empty( $markup['aggregateRating'] ) ) { $markup['aggregateRating'] = array( "@type" => "AggregateRating", "ratingValue" => "0", "reviewCount" => "0", ); } if ( empty( $markup['review'] ) ) { $markup['review'] = array( "@type" => "Review", "reviewRating" => array( "@type" => "Rating", "ratingValue" => "0", ), "author" => array( "@type" => "Person", "name" => "", ), ); } return $markup; }
This code displays both aggregateRating and Review as ‘0’ when no reviews have been written for a product.
However, this schema seems to stop working when I enable Rank Math. Is there a way to make it work in conjunction with Rank Math?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The ticket ‘How to use custom schema with Rank Math?’ is closed to new replies.