Notice: There is no legacy documentation available for this item, so you are seeing the current documentation.
In some cases, search engines like Google may display the publish date of your articles in their search results. If you'd like to prevent search engines from displaying the publish date, you can use the code snippet below to remove it from the JSON schema that AIOSEO outputs.
add_filter( 'aioseo_schema_output', 'aioseo_filter_schema_output' );
function aioseo_filter_schema_output( $schema ) {
foreach ( $schema as $index => $graphData ) {
if ( empty( $graphData['@type'] ) ) {
continue;
}
$type = strtolower( $graphData['@type'] );
switch ( $type ) {
case 'article':
case 'blogposting':
case 'newsarticle':
unset( $schema[ $index ]['datePublished'] );
unset( $schema[ $index ]['dateModified'] );
break;
default:
break;
}
}
return $schema;
}
NOTE:
Search engines may still display the published date of your articles after you've removed it from your schema markup. In that case, you must check if any other plugins or your theme are outputting dates in the source code.