Search code examples
phpwordpresslast-modified

Wordpress - Check if post has update


How can I check whether a post has been updated or not in Wordpress?

if (post_has_edit())
    the_modified_time();
else
    the_time();

Is there a function like post_has_edit()?


Solution

  • From the Wordpress docs:

    If the post or page is not yet modified, the modified time is the same as the creation time.

    So you can just use the_modified_time(), and if the post hasn't been modified, it will return the creation time instead.

    To check whether the post has been modified, check whether the_modified_time() == the_time().