How to show updated time if post was modified – WordPress

Would you like the updated date of a post only when the post was actually modified?

Compare the modified date with the date of publishing and show the text only if the modified is actually bigger.

Snippet

 <?php if ( get_the_modified_time('U') > get_the_time('U')) { ?>
    <p><small>Updated: <?=get_the_modified_date()?></small></p>
  <?php } ?>

Resources

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*