Add Published Date & Last Modified Date in WordPress

[ad_1]

Sometimes on a specific project, you have requirement to also display last modified date of pages and posts along with published date. So here is a code snippet to display both in your WordPress.

Posted on <?php the_time( 'F jS, Y' ); ?>
<?php
    // display last modified date
    $modified_time = get_the_time( 'U' );
    $new_modified_time = get_the_modified_time( 'U' );
    if ( $new_modified_time != $modified_time ) {
        echo " and last modified on ";
        the_modified_time( 'F jS, Y' );
        echo ".";
    }
?>
[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads