Archived topic
Auto Update of Dates on my pages
5 replies · Started by Soumyadip on August 29, 2018
Hi tom, i have gone thorugh this https://generatepress.com/forums/topic/how-to-display-last-updated-date-on-pages-and-posts/
The code above there is working fine and showing the dates on my pages but i want the date to be auto-updated every day.
Can you provide me a code, so that every day the date of my pages(pages only) automatically gets updated with new dates.
Regards Ranjit
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.