Created
March 11, 2025 00:52
-
-
Save sybrew/07a4d5110e5bae93a0fdee13b46a837d to your computer and use it in GitHub Desktop.
This filter for The SEO Framework (Articles extension) sets the Article Type to "NewsArticle" for 'post', 'web-story', and 'gira' post types.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do not include the PHP opening tag if PHP is already open | |
// Per email exchange with Renan. | |
add_filter( | |
'the_seo_framework_articles_data', | |
function ( $data ) { | |
if ( in_array( get_post_type(), [ 'post', 'web-story', 'gira' ], true ) ) { | |
// Set the article type to NewsArticle | |
$data['@type'] = 'NewsArticle'; | |
} | |
return $data; | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment