-
Hi there!
We run the PRO version! rainbowhelicopters.com here and we have hundreds of reviews on products. Is it advisable to limit them to 10 per product or some other number?
if ( ! function_exists( 'limit_reviews_in_product_schema' ) ) { /** * Callback to limit reviews in the product schema to 10 entries. * * @param array $entity The Product schema data array. * @return array Modified schema data with at most 10 reviews. */ function limit_reviews_in_product_schema( $entity ) { // Log when this function runs //error_log('RAINBOW SCHEMA FILTER: Product schema filter is running at ' . date('Y-m-d H:i:s')); // Only modify if there is a 'review' key with an array of reviews. if ( isset( $entity['review'] ) && is_array( $entity['review'] ) ) { // Limit the reviews array to the first 10 entries. $entity['review'] = array_slice( $entity['review'], 0, 10 ); } return $entity; } } // Attach our function to Rank Math's product schema filter with a high priority. add_filter( 'rank_math/snippet/rich_snippet_product_entity', 'limit_reviews_in_product_schema', 100, 1 );
As this code will run on products only is there advisable code/hook/filter I can run that will add in the TouristTrip schema and populate it’s parameters. Any tips for this would be amazing.
Best,
Dave
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The ticket ‘Limit reviews and TouristTrip schema’ is closed to new replies.