SLIM SEO Plugin – changing og:type article to website

Hello,

Does anyone here use SlimSEO?

I was testing Slim SEO and trying to remove ‘article:modified\_time’ and ‘article:published\_time’ from custom post types.

and also trying to change the <meta property=”og:type” content=”article”> to <meta property=”og:type” content=”website”> in the some CPTs.

Does anyone know how to do this? I was hoping to switch from Rankmath this week.

I tried the following code without luck:

add\_filter( ‘slim\_seo\_schema\_webpage’, function( $data ) {
// Define the custom post types from which you want to remove the dateModified and datePublished
$post\_types\_to\_exclude = \[‘wordpress’, ‘projects’, ‘solutions’, ‘page’\]; // Adding ‘page’ to the list

// Get the current post type
$post\_type = get\_post\_type();

// Check if the current post type is in the list of types to exclude
if ( in\_array( $post\_type, $post\_types\_to\_exclude, true ) ) {
// Remove the dateModified and datePublished if present
if ( isset( $data\[‘dateModified’\] ) ) {
unset( $data\[‘dateModified’\] );
}
if ( isset( $data\[‘datePublished’\] ) ) {
unset( $data\[‘datePublished’\] );
}
}

return $data;
});

add\_filter( ‘slim\_seo\_schema\_graph’, function( $graph ) {
if ( ! is\_singular( \[ ‘wordpress’, ‘projects’, ‘solutions’ \] ) ) {
return $graph;
}

foreach ( $graph as &$node ) {
if ( isset( $node\[‘@type’\] ) && ‘Article’ === $node\[‘@type’\] ) {
$node\[‘@type’\] = ‘WebSite’;
}
}

return $graph;
} );

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer