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()
?
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()
?
Comments are closed.
From the WordPress docs:
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()
.If you need check
date
for multiple post on same page (for example: archive page, search page or anyWP_Query
), you can useAnd remember use
!=
for is not equal 🙂