Remove article:modified_time Meta Tag
-
Aloha everyone,
First of all, thank you for the great plugin!
I’m looking for a solution to entirely remove the
article:modified_timemeta tag from all pages, posts and custom posts.It shows up when sharing in some messaging apps, and I don’t want/need that.
My search for hooks and filters was not successful.
Appreciate any hint!
Best wishes,
Beat
-
Hi @ekesto
You can use
wpseo_frontend_presentersfilter to remove theArticle_Modified_Time_Presenterfrom the page source.The Yoast SEO plugin code documents the available developer filters for customizing many of our plugin features. We also have a developer portal with more information about filters and many examples of how to implement them. Typically code snippets are added to your theme’s functions.php file. If you’re unfamiliar with using code snippets, we’d like to refer you to the WordPress documentation on how to use a filter.
We recommend creating regular backups of your site and database for your site’s health and safety. A backup is crucial before making important changes on your website and provides you with a safety net if something were to go wrong. Learn more about the benefits of regular backups.
Please know that, Google may still show the date in the search results even if the the date-related meta tags and schema are removed from your page source.
Hi Mushrit,
thanks for pointing me in the right direction!
For anyone interested in the solution of this specific case: I’ll post the code here (works with v24.4):
function remove_canonical_presenter($presenters) {
return array_map(function ($presenter) {
if (!$presenter instanceof Yoast\WP\SEO\Presenters\Open_Graph\Article_Modified_Time_Presenter) {
return $presenter;
}
}, $presenters);
}
add_action('wpseo_frontend_presenters', 'remove_canonical_presenter');This displays all but the modified time meta tag.
I had to use the class name including namespace to make it work.
Best wishes!
Thank you Ekesto, but in my Open Graph markup there is still a modified time, version 24.4
-
This reply was modified 1 year, 2 months ago by
Sam Smith.
@gepotenuz , the code above removes
<meta property="article:modified_time" content="2025-01-24T09:20:39+00:00" />in my case.By the way, for more clarity I would rename the callback function from
remove_canonical_presenterintocustom_theme_remove_article_modified_time_presenter.The published and modified date is still in the
<script type="application/ld+json" class="yoast-schema-graph">script, but this is not shown when sharing a website or post in messaging apps, which was what I was looking for.Good luck!
Thanks
-
This reply was modified 1 year, 2 months ago by
The topic ‘Remove article:modified_time Meta Tag’ is closed to new replies.