Skip to content

Instantly share code, notes, and snippets.

@GauravKhupse
Created September 21, 2021 06:07
Show Gist options
  • Save GauravKhupse/b0e4602779f2ee5d24c04cf0cc5813d5 to your computer and use it in GitHub Desktop.
Save GauravKhupse/b0e4602779f2ee5d24c04cf0cc5813d5 to your computer and use it in GitHub Desktop.
servesCuisine field in Food Establishment type.
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