• Resolved ekesto

    (@ekesto)


    Aloha everyone,

    First of all, thank you for the great plugin!

    I’m looking for a solution to entirely remove the article:modified_time meta 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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Mushrit Shabnam

    (@611shabnam)

    Hi @ekesto

    You can use wpseo_frontend_presenters filter to remove the Article_Modified_Time_Presenter from 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.

    Thread Starter ekesto

    (@ekesto)

    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 month, 2 weeks ago by Sam Smith.
    Thread Starter ekesto

    (@ekesto)

    @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_presenter into custom_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

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.