Wordpress - check if post is updated

How to check if 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()

?

+3


source to share


2 answers


From Wordpress docs :

If the post or page hasn't changed yet, the modified time is the same as the creation time.



So you can just use the_modified_time()

and if the message hasn't been modified it will return the creation time.

To check if a post has been modified, check if there is the_modified_time() == the_time()

.

+6


source


If you need date

validations for multiple posts on the same page (ex: archive page, search page or any WP_Query

), you can use

if(get_the_modified_date == get_the_date) :

    // Do stuff here

endif;

      



And don't forget to use !=

For does not equal :)

0


source







All Articles