• Resolved Tejas Hapani

    (@tejashapani-1)


    Hello,

    We are using ‘rank_math/snippet/rich_snippet_product_entity’ filter to set dynamic values for schema fields.

    But the issue is it’s not working with empty field.
    We need to set any value for fields then only it is replacing dynamic value.

    So I would like to set default values for product schema.

    For example, in Schema builder, I would like to set Product SKU, Price, Brand name, etc.. with default value.
    See this screenshot: https://ibb.co/3Wm2k1y

    I searched for hooks but don’t find any relevant hook.

    Is it possible to set default values using any filter or hook?

    Thanks

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

    (@rankmathteam)

    Hello @tejashapani-1,

    Thank you for reaching out to us.

    If you use a custom field to allocate data to your schema properties using our filter, you would need to modify your filter further.

    In this case, you can set a conditional statement to use a hard-coded fallback if the custom field returns an empty value like this:

    if(get_field('my_custom_field_brand', $post->ID, true)){ $entity['brand'] = get_field('my_custom_field_brand', $post->ID, true); }else{ $entiry['brand'] = 'Default Brand'; // or do nothing as Rank Math automatically adds default brand from the General Settings }

    Hope that helps.

    Thread Starter Tejas Hapani

    (@tejashapani-1)

    Hi,

    Thanks for your feedback.

    It’s not for custom field.
    I would like to set default value for default fields like Product SKU, Price, Brand name, etc..

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @tejashapani-1,

    Unfortunately, the schema fields in our schema generators don’t have the option to allow you to set default values. However, you can go ahead and create an individual or templated schema and add the initial values of Product SKU, Price, Brand Name, etc. Since you are using our filter to set dynamic values to your product schema, the filter will simply override those fields.

    If it seems that we are missing something, can you please share some further screenshots and more examples so we can provide further solutions accordingly?

    Looking forward to helping you.

    Thread Starter Tejas Hapani

    (@tejashapani-1)

    Here is a brief:

    We have a CPT called products with brand name, price, rating, sku data.
    now we added Rank math plugin and wanted to setup Schema for all products.

    By default, I set it from Rank Math > Title & Meta > Post Types: products and set Schema Type to ‘Products’.

    so all products will have product schema type. All good so far.

    Now when I edit any products and check the schema, it has all fields blank.
    And on frontend, it is not showing any of the fields.

    I already have filter to overwrite values for fields, I first need to set default value for each fields to update the values on frontend which is like to much work for thousands of products.

    Is there any option that we can set default values for fields? so we don’t have to go to each products and set default values.

    Hope this will make more sense.

    Let me know if you need any further clarificaitons.

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @tejashapani-1,

    This can be solved by using the Schema Templates available in the PRO version of the plugin. If you create a template for the products with some dummy default values it will apply those on the products and then change dynamically based on the filter you currently have.

    In the Free version of the plugin those sorts of templates are not available so you would need to add the data manually if you are using that version of the plugin.

    Don’t hesitate to get in touch if you have any other questions.

    Thread Starter Tejas Hapani

    (@tejashapani-1)

    Okay. Got it.

    I managed it to add manually.

    Thanks for your support.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to set default values for Schema variables?’ is closed to new replies.