Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
You will need to tell Rank Math to add this data to the product schema by hooking into the following filter:
/**
* Filter to modify product schema
*
* @param array $entity Snippet Data
* @return array
*/
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
$entity['gtin8'] = 'Enter 8 digit ean here or create some logic to populate the value';
return $entity;
});
Looking forward to helping you. Thank you.
Where exactly I put that?
Hi Jani,
Thanks for the follow up.
This will need to go to your theme’s functions.php file.
I hope this info helps.
I put that into that and I finded code from Google that I get that attribute info to that ean. But it won’t show at schema.
/**
* Filter to modify product schema
*
* @param array $entity Snippet Data
* @return array
*/
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
global $product;
$ean = $product->get_attribute( 'ean' );
$entity['gtin8'] = "$ean";
return $entity;
});
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.