Skip to content

Instantly share code, notes, and snippets.

@GauravKhupse
Last active June 30, 2022 11:41
Show Gist options
  • Save GauravKhupse/864af7416335dd2bb2774359582fed20 to your computer and use it in GitHub Desktop.
Save GauravKhupse/864af7416335dd2bb2774359582fed20 to your computer and use it in GitHub Desktop.
Added author and publisher same as field URL as home page URL
add_filter( 'wp_schema_pro_schema_review', 'my_extra_schema_field_mapping', 10, 3 );
/**
* Mapping extra field for schema markup.
*
* @param array $schema Schema array.
* @param array $data Mapping fields array.
* @return array
*/
function my_extra_schema_field_mapping( $schema, $data, $post ) {
if ( isset( $data['reviewer-name'] ) && ! empty( $data['reviewer-name'] ) ) {
$schema['author']['sameAs'] = home_url();
}
if ( isset( $data['publisher-name'] ) && ! empty( $data['publisher-name'] ) ) {
$schema['publisher']['sameAs'] = home_url();
}
return $schema;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment