Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yumyo/fa7598d20edd970e5d783fba85d2c325 to your computer and use it in GitHub Desktop.
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
<?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