Created
September 21, 2021 06:07
-
-
Save GauravKhupse/b0e4602779f2ee5d24c04cf0cc5813d5 to your computer and use it in GitHub Desktop.
servesCuisine field in Food Establishment type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wp_schema_pro_schema_meta_fields', 'my_extra_schema_field' ); | |
add_filter( 'wp_schema_pro_schema_local_business', 'my_extra_schema_field_mapping', 10, 3 ); | |
function my_extra_schema_field( $fields ) { | |
$fields['bsf-aiosrs-local-business']['subkeys']['servesCuisine'] = array( // `bsf-aiosrs-book` used for Book, `bsf-aiosrs-event` will for Event like that. | |
'label' => esc_html__( 'Serves Cuisine', 'aiosrs-pro' ), // Label to display in Mapping fields | |
'type' => 'text', // text/date/image | |
'default' => 'none', | |
); | |
return $fields; | |
} | |
function my_extra_schema_field_mapping( $schema, $data, $post ) { | |
if ( isset( $data['servesCuisine'] ) && ! empty( $data['servesCuisine'] ) ) { | |
// For date/text type field | |
$schema['servesCuisine'] = esc_html( $data['servesCuisine'] ); | |
} | |
return $schema; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment