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.


<?php if ( get_the_modified_time('U') > get_the_time('U')) { ?> <p><small>Updated: <?=get_the_modified_date()?></small></p> <?php } ?>
Code language: HTML, XML (xml)


About Ricard Torres

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

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> if you need to.