GTIN in Schema

  • I need to add GTIN to the schema for woocom products – it is using a field called “ean” which has been populated for all products.
    Can I do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can make use of the following filter to pass the EAN field value to the Rank Math schema:

    /**
     * Filter to add Brand Name for Products.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        $entity['gtin8'] = ''; //pass the value here
        return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Thanks for that.

    What code do I need to place to pass the value?
    The field name is “EAN”.

    Thanks
    Jack

    Hello,

    Chitra, could you open a new thread so we can help you there (so you can add any extra info in the Sensitive Data field)?

    Jack, about your question, meanwhile we don’t usually provide custom code and also I don’t know how you are storing that field in the database (using custom post meta? using acf fields?), I have modified the previous code and it should work for you (or just need a few tweaks if not):

    /**
     * Filter to add Brand Name for Products.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        $entity['gtin8'] = get_post_meta(get_the_ID(), 'ean', TRUE);
        return $entity;
    });

    Hope it helps.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘GTIN in Schema’ is closed to new replies.