mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
23 lines
514 B
Text
23 lines
514 B
Text
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;
|
|
}
|