-
Hi Team,
I want to remove datePublished and dateModified from the Schema for some posts so that Google don’t show the post date with Google search.
-
Hello,
Thanks for contacting us, and sorry for any inconvenience that might have been caused due to that. We deeply apologize for the delay in response.
As you don’t want to show your post’s date on Google SERPs, here are some reference below that may help you to understand on what you need to do in this case.
According to Google’s John Mueller it is useful to check out your published HTML page and in your browser select to “view code” in order to see if there’s something there that is sending date information to Google.
And if you find some published date information in the HTML code that you don’t want published in Google’s SERPs then the next step would be to find out what’s part of your code is generating that date and remove it.
According to our examination on this matter, we could interpret that search engines display dates when they’re clearly visible inside the content. Hence to completely remove the date from SERP, we request you to get in touch with your theme provider.
Here’s a URL below for your reference:
https://rankmath.com/kb/remove-dates-from-search/#num-2-1-visible-date-inside-the-contentIn short, removing those in Schema does not usually guarantee that Google will stop showing the date from the SERPs, but you may try following the guide and reference mentioned above to learn how you can achieve that.
However, if you still wish to remove
datePublishedanddateModifiedfrom the Schema for specific posts on your site, you may try applying the following filteradd_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; } );Here’s a guide on how you can add filters/hooks to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.
Thank you.
Hi,
I tried to remove the datePublished and dateModified with the above hook, but it removes the second entry but not the first.
———————————–
{“@context”:”https://schema.org”,”@graph”:[{“@type”:”Organization”,”@id”:”http://dev.acsi.freelife/#organization”,”name”:”ACSI FreeLife”,”url”:”http://dev.freelife.acsi”,”logo”:{“@type”:”ImageObject”,”@id”:”http://dev.acsi.freelife/#logo”,”url”:”http://dev.freelife.acsi/wp-content/uploads/2016/10/freelife_logo.png”,”caption”:”ACSI FreeLife”,”inLanguage”:”nl”,”width”:”321″,”height”:”96″}},{“@type”:”WebSite”,”@id”:”http://dev.acsi.freelife/#website”,”url”:”http://dev.acsi.freelife”,”name”:”ACSI FreeLife”,”publisher”:{“@id”:”http://dev.acsi.freelife/#organization”},”inLanguage”:”nl”},{“@type”:”ImageObject”,”@id”:”http://dev.acsi.freelife/wp-content/uploads/2021/12/header-videoblog-6-gezin.jpg”,”url”:”http://dev.acsi.freelife/wp-content/uploads/2021/12/header-videoblog-6-gezin.jpg”,”width”:”1540″,”height”:”1027″,”caption”:”Eindvideo gezin 2021″,”inLanguage”:”nl”},{“@type”:”Person”,”@id”:”http://dev.acsi.freelife/auteur/jeroen-timmermans/”,”name”:”Jeroen Timmermans”,”url”:”http://dev.acsi.freelife/auteur/jeroen-timmermans/”,”image”:{“@type”:”ImageObject”,”@id”:”http://dev.acsi.freelife/wp-content/uploads/2021/12/Gezin-header-videoblog4.jpg”,”url”:”http://dev.acsi.freelife/wp-content/uploads/2021/12/Gezin-header-videoblog4.jpg”,”caption”:”Jeroen Timmermans”,”inLanguage”:”nl”},”worksFor”:{“@id”:”http://dev.acsi.freelife/#organization”}},{“@type”:”WebPage”,”@id”:”http://dev.acsi.freelife/tips-trends/eindoordeel-gezinskampeerders-testtour/#webpage”,”url”:”http://dev.acsi.freelife/tips-trends/eindoordeel-gezinskampeerders-testtour/”,”name”:”Dit vonden de Gezinskampeerders van de TestTour! | ACSI FreeLIfe”,”datePublished”:”2021-12-22T18:31:39+01:00″,”dateModified”:”2022-11-30T13:20:56+01:00″,”author”:{“@id”:”http://dev.acsi.freelife/auteur/jeroen-timmermans/”},”isPartOf”:{“@id”:”http://dev.acsi.freelife/#website”},”primaryImageOfPage”:{“@id”:”http://dev.acsi.freelife/wp-content/uploads/2021/12/header-videoblog-6-gezin.jpg”},”inLanguage”:”nl”},{“image”:{“@id”:”http://dev.acsi.freelife/wp-content/uploads/2021/12/header-videoblog-6-gezin.jpg”},”headline”:”Dit vonden de Gezinskampeerders van de TestTour! | ACSI FreeLIfe”,”description”:”Het was een avontuur om nooit meer te vergeten voor de familie Loykens. Kijk de laatste video met het eindoordeel van de Gezinskampeerders 2021″,”keywords”:”eindoordeel Gezinskampeerders 2021″,”@type”:”Article”,”author”:{“@id”:”http://dev.acsi.freelife/auteur/jeroen-timmermans/”},“datePublished”:”2021-12-22CET18:31:39+01:00″,”dateModified”:”2022-11-30CET13:20:56+01:00″,”name”:”Dit vonden de Gezinskampeerders van de TestTour! | ACSI FreeLIfe”,”@id”:”http://dev.acsi.freelife/tips-trends/eindoordeel-gezinskampeerders-testtour/#schema-195380″,”isPartOf”:{“@id”:”http://dev.acsi.freelife/tips-trends/eindoordeel-gezinskampeerders-testtour/#webpage”},”publisher”:{“@id”:”http://dev.acsi.freelife/#organization”},”inLanguage”:”nl”,”mainEntityOfPage”:{“@id”:”http://dev.acsi.freelife/tips-trends/eindoordeel-gezinskampeerders-testtour/#webpage”}}]}
Hello,
Are you trying to remove the dates from all the posts with the Article Schema?
You can use the following filter for that:
add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $entity ) { unset( $entity['datePublished'] ); unset( $entity['dateModified'] ); return $entity; } );Hope this helps solve your issues.
Don’t hesitate to get in touch if you have any other questions.
Hello,
No, i want to remove it from the article that i want.
At present the above snippet is removing but but for a single article i am getting 3 date entries and the above snippet is removing only one date entry but other 2 are remaining. So, for each article i want to remove all the date entries from a particular article.
Thanks in advance
Hello,
Please try replacing the old code snippet with the following one to see if that works for you:
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; } ); 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);Let us know how it goes. Looking forward to helping you.
Thank you.
Hello,
I’ll check this solution and will update you soon about it.
Thank you
Hello,
Sure! Let us know how it goes.
Meanwhile, please do not hesitate to let us know if you need our assistance with anything else.
Thank you.
Hi,
Sure will share the update soon.
Thank you
Hello,
We are going to close this ticket for now due to inactivity but if you have anything else to add you can always open a new one and reference the URL of this one.
Thank you.
The ticket ‘I need to remove datePublished and dateModified from the Schema’ is closed to new replies.