Adding MPN to rich snippets

#212631
  • Resolved Beauty Crush
    Rank Math free

    Hi there,
    I have installed plugin “Product GTIN (EAN, UPC, ISBN) for WooCommerce” as I have read in many of the suggestions here on the help forums.

    I have used ‘MPN’ for the “Label of GTIN Code” within the plugin settings.
    I tried to add something along the lines of this to the functions.php:

    add_filter( “rank_math/snippet/rich_snippet_product_entity”, function( $entity ) {
    $entity[‘mpn’] = get_post_meta( $post->ID, ‘_wpm_gtin_code’);
    return $entity;
    });
    ?>

    I have tried to change ‘_wpm_gtin_code’ to ‘mpn’, ‘_mpn’ etc to no avail. It is still not showing up in google rich results test.

    Can you please assist?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Brian
    Rank Math free

    Hello,

    Thank you for contacting Rank Math today:

    This would depend on the GTIN type you have inserted on the Structured data product. See screenshot of this section: https://i.rankmath.com/DJWly7.

    If you have set this to gtin or gtin8/13 then you can use the code:

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

    If you have set a different GTIN type like MPN, then you need to change it with 'mpn'.

    Please let us know if that works. We are looking forward to helping you.

    Thank you.

    Cesar
    Rank Math free

    Is it possible to use GTIN and MPN at the same time?

    I can only choose one or the other.

    Nigel
    Rank Math business

    Hello,

    You can use both GTIN and MPN on a single product. However, there is no clear documentation on this. You may refer to the following Google forum thread: https://support.google.com/webmasters/thread/112076091/can-we-use-multiple-gtins-and-or-mpns-in-product-schema?hl=en

    Hope that helps. If you have questions, please ask. We are here to help.

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

You must be logged in to reply to this ticket.