Last active
June 30, 2022 11:41
-
-
Save GauravKhupse/864af7416335dd2bb2774359582fed20 to your computer and use it in GitHub Desktop.
Added author and publisher same as field URL as home page URL
This file contains hidden or 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_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