[Resolved] Remove dateModified from HTML

Home Forums Support Remove dateModified from HTML

This topic contains 7 replies, has 2 voices, and was last updated by  Tom 6 days ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #1082939



    Is it possible to remove Modified Date from the HTML, rather than just hiding it with CSS?


    Tom Lead Developer

    You don’t want the modified date at all? If not, try this PHP:

    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
        $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
        $time_string = sprintf( $time_string,
            esc_attr( get_the_date( 'c' ) ),
            esc_html( get_the_date() )
        return sprintf( '<span class="posted-on">%s</span> ',
    }, 10, 2 );

    Let me know 🙂



    Hi Tom,

    Thanks for this but it doesn’t seem to have worked. I can still see the date in the html, with display: none; set. I have edited my initial post to show the URL

    Out of interest, why do you hide it with CSS rather than remove it with PHP when a user has opted not to include it in the GP settings? 🙂


    Tom Lead Developer

    Are you already using a function to alter the post meta/date? Your HTML on the site doesn’t reflect the function I mentioned above.

    The GP setting to remove the date should fully remove the date from the HTML.

    Let me know 🙂



    Ah yes you were correct, I had some more code in there so I have now combined the two.

    Also, apologies as I was mistaken about the setting to remove the date.

    I had misremembered and thought there were separate options to show Date Published and Date Modified, but there is only a single option to control the date being shown.

    My concern with hiding things via CSS is that it can look deceptive from an SEO point of view. I don’t think that is an issue here, but I prefer to just remove it if it is not being used.


    Tom Lead Developer

    In most cases, Google knows whether you’re being deceptive or not.

    Did you get the above function working now?

    Let me know 🙂



    Yes I did, thank you.


    Tom Lead Developer
Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.