How to set default values for Schema variables?

[ad_1]

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.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer