How To Show Last Updated/Modified Date In WordPress Site

Showing the date of published or last updated your WordPress articles helps your visitors to know that how long back this information was published. In addition, it also boost your site’s SEO ranking as Google like it to display the last updated time and date information in posts. In this post I’ll tell you to display last updated or modified date in the posts.

How To Show Last Updated/Modified Date In WordPress
#image_title

Method 1: Using WordPress Theme Settings (If Available)

Most of the WP themes have built-in feature to display last modified date and time in the post. This option mostly comes with name of Meta options in themes settings. If your theme support this feature then you can enable it from themes settings.

  1. Log in to your WordPress Dashboard.
  2. Go to Appearance > Customize.
  3. Search for a setting related to Post Meta or Date Settings.
  4. Check if there is an option to display the “Last Updated” date. If available, enable it.
  5. Save and publish your changes.

Method 2: Modify Your Theme’s functions.php File

If your theme doesn’t have a built-in feature then you can add out custom code into your theme’s functions.php file to display the last updated date.

  1. Log in to your WordPress Dashboard.
  2. Navigate to Appearance > Theme Editor.
  3. Open your theme’s functions.php file.
  4. Copy the below code and paste it at the last of the code in your file.

// By earngrip.com
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time>';

    if ( get_the_date() !== get_the_modified_date() ) {
        $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>';
    }

    $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_attr( get_the_modified_date( 'c' ) ),
        esc_html( get_the_modified_date() )
    );

    return sprintf( '<span class="posted-on">%s</span> ',
        $time_string
    );
}, 10, 2 );
Sharing Is Caring:

Kaka MEO is a skilled blogger and content writer specializing in making money and education topics. He crafts engaging content that informs and empowers readers to achieve financial and educational success.

Leave a Comment