How to Fix Missing Fields in RankMath Product Schema?

#929546
  • Vincent
    Rank Math free

    I’m using the RankMath free plugin to generate a product schema. My product data is created using ACF, and I noticed in GSC that some fields, like shippingDetails and hasMerchantReturnPolicy, are missing. I tried adding code to functions.php to include these fields in the RankMath schema, but it’s not working. Any suggestions?

    add_filter(‘rank_math/json_ld’, function($data, $jsonld) {
    if (!is_singular(‘your_custom_post_type’)) {
    return $data;
    } // replace ‘your_custom_post_type’ to ‘product’

    $data[‘offers’][0][‘priceValidUntil’] = ‘2024-12-31’;
    $data[‘offers’][0][‘hasMerchantReturnPolicy’] = [
    ‘@type’ => ‘MerchantReturnPolicy’,
    ‘returnPolicyCategory’ => ‘https://schema.org/MerchantReturnFiniteReturnWindow’,
    ‘returnFees’ => ‘https://schema.org/FreeReturn’
    ];
    return $data;
    }, 10, 2);

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

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

    From the code, you should change the custom post type in this line:
    if (!is_singular(‘your_custom_post_type’)) {

    to

    if (!is_singular('product')) {
    

    Here’s our guide to fix these warnings in your products:
    https://rankmath.com/kb/merchant-return-and-shipping-policy/

    Looking forward to helping you.

    Vincent
    Rank Math free

    Yes, I changed it to ‘product’ but it’s not added to the schema.

    Hello,

    Please share the actual code/filter you have added so we can check.

    Also, we may need to check the schema generated, so please share the product URL.

    You can add it to the sensitive data section by editing your first post

    Sensitive Data Section

    It is completely secure, and only our support staff has access to that section.

    Looking forward to helping you.

    Vincent
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    We’ve noticed that the filter in the Pastebin link you shared seems different from the one you shared initially.

    However, upon checking the code you have applied, the properties are already appearing in the schema.

    Please refer to the result link in the sensitive data section.

    Looking forward to helping you.

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

You must be logged in to reply to this ticket.