Site logo

Archived topic

Auto Update of Dates on my pages

5 replies · Started by Soumyadip on August 29, 2018

Viewing posts 1–6 of 6

Just to clarify you want the Updated Date to always be todays date?

yes i want to show last Updated Date to always be todays date

Hmm, not sure that's a great idea SEO-wise. It's likely do-able, but every single post would show the same date and time, which might look broken?

i want to do this in one specific page

You could try a function like this:

add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    if ( 10 === get_the_ID() ) {
        $time_string = sprintf( 
            '<time class="updated" itemprop="dateModified">%s</time>',
            date( get_option( 'date_format' ) )
        );
    }

    return $output;
}, 10, 2 );

Just update the 10 to the ID of your post.

This archived topic is closed to new replies.