Skip to content

Instantly share code, notes, and snippets.

@schemapress
Last active January 24, 2019 20:24
Show Gist options
  • Save schemapress/752097d54d4e88171fb0cbd8ac520f4e to your computer and use it in GitHub Desktop.
Save schemapress/752097d54d4e88171fb0cbd8ac520f4e to your computer and use it in GitHub Desktop.
Remove datePublished markup on BlogPosting https://schema.press/remove-datepublished-markup-posts/
<?php //* do not include php tag
add_filter('schema_output', 'remove_datePublished_markup_588545256');
/**
* Schema Plugin: Remove datePublished markup on BlogPosting
*
* @since 1.0
*/
function remove_datePublished_markup_588545256( $schema ) {
// If markup is for BlogPosting,
// return our $json array and do not do anything
if ( isset($schema['@type']) && $schema['@type'] != 'BlogPosting' ) return $schema;
// Unset the published date
unset( $schema["datePublished"] );
// Unset the modified date (last updated date)
unset( $schema["dateModified"] );
return $schema;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment