WordPress.org

Ready to get started?Download WordPress

Forums

Show Modified Date only if modified (3 posts)

  1. StyledThemes
    Member
    Posted 1 year ago #

    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') );

  2. wpismypuppet
    Member
    Posted 1 year ago #

    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:

    http://codex.wordpress.org/Class_Reference/wpdb

    And use the posts table to gather the post_date field.

  3. StyledThemes
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic