On December 31, 2019, I learned...

How to display the WordPress post date and modified date, if modified

Had to look this up, but it makes a lot of sense when it’s typed out. Grab the current date and the post date, then compare the two. If the difference is zero, then only show the post date. If the difference is one or higher, show both.

= $j_time + 1) { echo the_date('F j, Y'); echo "Updated: "; the_modified_time('F j, Y'); } else { echo the_date('F j, Y'); } ?>

Leave a Reply

Markdown supported