-
Hi there!
I’ve attempted to go through the various guides you have regarding the subject, including:
https://rankmath.com/kb/remove-dates-from-search/
However, despite this I’ve been unable to remove both datePublished and dateModified from my product pages. Here’s an example URL from the website for inspection: https://www.greenbalance.se/butik/pigment/mineralpigment/ultramarinviolett/Here’s how my code currently looks:
// Remove
datePublished
anddateModified
from the JSON-LD structured data for WebPage
add_filter( ‘rank_math/json_ld’, function( $data ) {
if ( isset( $data[‘WebPage’] ) ) {
$data[‘WebPage’][‘datePublished’] = ”;
$data[‘WebPage’][‘dateModified’] = ”;
}
return $data;
});// Remove
datePublished
anddateModified
from the product entity and reviews
add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
if ( isset( $entity[‘datePublished’] ) ) {
$entity[‘datePublished’] = ”;
}
if ( isset( $entity[‘dateModified’] ) ) {
$entity[‘dateModified’] = ”;
}if ( isset( $entity[‘review’] ) ) {
foreach ( $entity[‘review’] as $key => $review ) {
if ( isset( $review[‘datePublished’] ) ) {
$entity[‘review’][$key][‘datePublished’] = ”;
}
if ( isset( $review[‘dateModified’] ) ) {
$entity[‘review’][$key][‘dateModified’] = ”;
}
}
}return $entity;
});// Remove Open Graph date properties
add_filter( ‘rank_math/opengraph/facebook/og_updated_time’, ‘__return_false’ );
add_filter( ‘rank_math/opengraph/facebook/article_published_time’, ‘__return_false’ );
add_filter( ‘rank_math/opengraph/facebook/article_modified_time’, ‘__return_false’ );// Remove lastmod from sitemap index
add_filter( ‘rank_math/sitemap/index/entry’, function( $entry, $type ) {
if ( isset( $entry[‘lastmod’] ) ) {
unset( $entry[‘lastmod’] );
}
return $entry;
}, 10, 2 );
The ticket ‘Unable to Remove Date Snippets from Search Results’ is closed to new replies.