Forked from schemapress/schema-wp-extend-output.php
Created
January 19, 2017 16:37
-
-
Save yumyo/fa7598d20edd970e5d783fba85d2c325 to your computer and use it in GitHub Desktop.
Extend / Override Schema.org JSON_LD Output in WordPress Schema Plugin http://schema.press
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
<?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