Remove publish date from article schema in All in One SEO

Remove publish date from article schema in All in One SEO on child sites.

Snippet Type

Execute on Child Sites

Snippet

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;
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.