• Resolved cityvanhawk

    (@cityvanhawk)


    Hi, I have a website where GTIN12 already exists in my product attributes as GTIN12 value. How would I add it so google rich snippets recognizes it? I tried code below but it does not work:

    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    $entity[‘gtin12’] = get_post_meta(get_queried_object_id(), ‘pa_gtin12’, true);
    return $entity;
    });

Viewing 1 replies (of 1 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @cityvanhawk,

    Thank you for contacting the support and sorry for any inconvenience that might have been caused due to that.

    Please use the filter given below to fetch the GTIN from your product attribute:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    $entity['GTIN'] = get_post_meta(get_queried_object_id(), 'pa_gtin12', true);
    return $entity;
    });

    You can follow this guide to add the filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how that goes. Looking forward to helping you.

Viewing 1 replies (of 1 total)
  • The topic ‘GTIN Already Exists in Attributes’ is closed to new replies.