If you want to show the updated time of your WordPress post, you can use the following function on your theme’s single.php & archive.php pages. Ideal spot to place the following line should be after the default WordPress date and time function.
<?php post_updated_time('F jS, Y');?>
Simply go to the functions.php file of your theme and place the following snippet.
<?php
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time 86400) {
echo ", Updated: ";
post_updated_time('M j, Y'); }
?>
By default, updated time will not be visible. It will be shown only after re-editing any published post. To test it out, you should try with any post which is at least a day old.
Comment
Leave a Reply