Skip to content

Instantly share code, notes, and snippets.

@sybrew
Created March 11, 2025 00:52
Show Gist options
  • Save sybrew/07a4d5110e5bae93a0fdee13b46a837d to your computer and use it in GitHub Desktop.
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.
<?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