Add the modification date of a WordPress Article

A small snippet to add the modification date of an item if it has been modified since its first publication. Not displayed if the modification occurred on the same day. A function to add to the functions.php file of your theme.

To be at your template, better use
the_modified_date()


function date_modified_add($content){

    if(is_single()){

        global $post;
        if(date('dmY',strtotime($post->post_date))!=date('dmY',strtotime($post->post_modified)))
        return '

Dernière modification le : '.date_i18n(get_option('date_format'),strtotime($post->post_modified)).'
'.$content;

    }

    return $content;

}

add_filter('the_content','date_modified_add');

Post a Comment

0 Comments