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