Manish Kumar
  • Home
  • About Me
  • Portfolio
  • Services
  • Blog
  • Contact Me

Connect with me

© 2026 Manish Kumar.

Remove the date snippet from the RankMath schema

Blog, RankMath Dec 20, 2022
remove-date-snippet-from-google-search-results

Losing traffic on the website can be risky!

Suppose, you wrote a wonderful article but suddenly stop getting enough traffic to your article page after some time.

Google shows the old date of your article and makes readers think that the article doesn’t have updated information.

Here, we’ll show you how you can remove the date snippet and other JSON data in the RankMath schema.

You need to add the below codes to the function.php file.

Removes date snippet from all posts

add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $entity ) {

	unset( $entity['datePublished'] );
	unset( $entity['dateModified'] );
	
    return $entity;
} );

Removes date snippet from the selective posts

add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $entity ) {
	global $post;
	$remove_ids = array(1,2,3); // Replace 1,2,3 with your post ID(s)
	
	if(!empty($post->ID) && is_numeric($post->ID) && in_array((int)$post->ID, $remove_ids)){
		unset( $entity['datePublished'] );
		unset( $entity['dateModified'] );
	}
    return $entity;
} );

Removes other JSON data in the schema from all posts

add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {

	unset ($data['WebPage']['dateModified']);
	unset ($data['WebPage']['datePublished']);

	return $data;
}, 99, 2);

Removes other JSON data in the schema from the selective posts

add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
	global $post;
	$remove_ids = array(1,2,3); // Replace 1,2,3 with your post ID(s)
	
	if(!empty($post->ID) && is_numeric($post->ID) && in_array((int)$post->ID, $remove_ids)){
		unset ($data['WebPage']['dateModified']);
		unset ($data['WebPage']['datePublished']);
	}
	return $data;
}, 99, 2);
Share This Post
Facebook Twitter Linkedin Google+
Older

Leave A Comment