Support » Fixing WordPress » Show Modified Date only if modified

  • Unless I missed it somewhere, is there a way to only show the modified date when a post or page has been updated? I noticed that the modified date shows even with a new post that has not been updated (modified).

    Right now my code is this in my single.php file:
    the_modified_date( 'F j, Y', __( 'Last Modified: ', 'st') );

Viewing 2 replies - 1 through 2 (of 2 total)
  • wpismypuppet


    I tend to think that you’d want the date no matter what. This way people know when the file was last “updated”, even if it means that is when the file was created! This let’s people know how old the content is.

    To answer your question though, you would need a custom SQL query before you pump out the modified date. You’ll need to gather the “post_date” and compare that to the modified date. If they are equal, don’t echo the_modified_date. If they aren’t equal, show it!

    Read up on:

    And use the posts table to gather the post_date field.

    sounds too much work at the moment because of my schedule…it’s only an optional feature to pursue but will do this another time. I’ll keep it as-is for now, but thank you for the reply and info; will read up on the Class_Reference/wpdb

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show Modified Date only if modified’ is closed to new replies.