Last active
September 28, 2017 19:43
-
-
Save schemapress/abf19698e702da7f27787d9bcb033e53 to your computer and use it in GitHub Desktop.
Extend / Override Schema.org JSON_LD Output https://schema.press/docs/extend-schema-output/
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
<?php //* do not include php tag | |
add_filter('schema_output', 'schema_wp_extend_output_987345256'); | |
/** | |
* Extend / Override Schema Output | |
* | |
* @since 1.0 | |
*/ | |
function schema_wp_extend_output_987345256( $schema ) { | |
global $post; | |
if ( empty($schema) ) return; | |
// Debug | |
// echo '<pre>'; print_r($schema); echo '</pre>'; | |
// Modify NewType to present the actual schema.org type | |
if ( $schema['@type'] != 'NewType' ) return $schema; | |
// Modify / Override values | |
$schema['title'] = 'New Title'; | |
// Add new values | |
$schema['name'] = 'Event Name'; | |
$schema['startDate'] = '2016-07-10T06:00'; | |
// Unset extras | |
unset($schema['headline']); | |
unset($schema['author']); | |
unset($schema['publisher']); | |
unset($schema['ArticleSection']); | |
return $schema; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment