Reputation: 818
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()
?
Upvotes: 3
Views: 3907
Reputation: 88
If you need check date
for multiple post on same page (for example: archive page, search page or any WP_Query
), you can use
if(get_the_modified_date == get_the_date) :
// Do stuff here
endif;
And remember use !=
for is not equal :)
Upvotes: 0
Reputation: 20359
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()
.
Upvotes: 8