Globally Make MPN Use SKU

#350018
  • Resolved SoonerKnives
    Rank Math free

    I do not have RankMath Pro; I use the free version. I get the warning in Rich Results Test that a global identifier is missing.

    I would like to globally report the SKU value in each product as the MPN in SEO results. How can I accomplish this?

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

    Thank you for contacting us and bringing your concern to our attention.

    You can use filter hooks to add/edit the SKU in your product schema. Please check the sample code below.

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        $entity['sku'] = 'YOUR_GLOBAL_IDENTIFIER';
        return $entity;
    });

    You need to add it to your functions.php in your theme files.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    I meant that the rule should be applied globally, not that there is a global value used for MPN. I need each item’s MPN value to be populated by each item’s SKU value. This is not one value globally.

    Please advise.

    Hello,

    You will have to modify the filter to fetch the SKU value from the database. You can try using the filter given below:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        global $product;
        $entity['mpn'] = $product->get_sku();
        return $entity;
    });

    Hope this helps. Let us know if you need any other assistance.

    Thanks.

    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 ‘Globally Make MPN Use SKU’ is closed to new replies.