Site logo

Archived topic

Post "Updated on" to reflect ModifiedTime

10 replies · Started by Ivaylo on December 30, 2022

Viewing posts 1–11 of 11

Hi,
I'm using this code:
add_filter( 'generate_post_date_output','tu_add_to_post_date' );
function tu_add_to_post_date( $output ) {
return '<span class="date-label">Updated on </span>' . $output;
}

to show the date the post is updated. But it shows the published time ( PublishedTime ) instead the one I updated the post ( which I can see in ModifiedTime )

See the attached screenshot:

Hi there

can i see the issue on your site ?

Sure, link is below:
I just updated this post ( 30.12.2022 ), but it still showing the date 22.12.2022 when I edited the post and hit Publish instead of Update.
I want to show the date the post was updated as it is noted in ModifiedTime in the schema/dev tools.

So I should place all of the following in my functions.php:

add_filter( 'generate_post_date_output','tu_add_to_post_date' );
function tu_add_to_post_date( $output ) {
return '<span class="date-label">Updated on </span>' . $output;
}

add_filter( 'generate_post_date_show_updated_only', '__return_true' );

Because I want to have "Updated on" before the date.

Is there a more elegant and shorter filter function for the above two?

Using those 2 snippets are as elegant as it gets :)

Thanks! Happy Holidays!

And Happy Holidays to you :)

This archived topic is closed to new replies.