Hi!
I am displaying the published and modified dates in all my posts using the code bellow:
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = '<time class="entry-date published" datetime="%1$s" >%2$s</time>';
if ( get_the_date() !== get_the_modified_date() ) {
$time_string = 'Sist oppdatert: <time class="entry-date updated-date" datetime="%3$s">%4$s</time><time class="entry-date published" datetime="%1$s">%2$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
return sprintf( '<span class="posted-on">%s</span> ',
$time_string
);
}, 10, 2 );
The problem is that when scheduling a post it shows the modified date earlier than the published date, for example if I schedule a post for a week from now, it will show like this:
last modified 15 jan 2021 / published 22 jan 2021
How can I make the modified date show only if the date is later than the posted date?
thanks!