-
In order to fully comply with google product schema, i have this snippet in my functions.php:
add_filter( 'woocommerce_structured_data_product', 'bomberomania_microdata', 10, 2 ); function bomberomania_microdata( $markup, $product ){ // // We collect reviews instore and from a 3rd party. Sometimes 3rd party send incompatible value, so we fix here // // if ( isset($markup['aggregateRating']) ) { if ( $markup['aggregateRating']['ratingValue'] > 5 || $markup['aggregateRating']['ratingValue'] <= 1 ){ $markup['aggregateRating']['ratingValue'] = 5; } } // Woocommerce attribute pa_marca as "brand" is already set in rankmath setup. // But in some products pa_marca is empty, so we fix here $brand = $product->get_attribute('pa_marca'); $brands = explode( ',', $brand ); if ( ! empty( $brands ) ) { $marca = $brands[0]; }else{ $marca = 'BOMBEROMANÍA'; } $markup['brand'] = array( '@type' => 'Brand', 'name' => $marca, ); // We use product Gtin codebar as our sku. No need to add another field, just fill from there $markup['gtin13'] = $product->get_sku(); return $markup; }
Issue is, now that we use rankmath, i’m not getting this values in frontstore
How can i translate this snippet to rankmath’s code?
We have 2000+ products in our store and this simplify management, so everything must be done in this bulk way
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The ticket ‘Product schema issue’ is closed to new replies.