Put last modified / last Updated date in WordPress

2 minutes read

You might have noticed that some WordPress blogs show a last modified or last updated date in place of the published date on the posts or pages. If you’re looking to add the same functionality to your blog too, this tutorial will going to help you to achieve that – we’ll see the both the DIY way and using plugins to accomplish that.

WordPress plugin to show last modified date

I’ve written a WordPress plugin called WP Last Modified that allows you to add last modifed date to your WordPress posts and pages in a controlled way. You may also add Revised meta tags to your WordPress posts and pages with it, but it’s completely optional.

WP Last Modified WordPress plugin »

Show Last modified date manually in WordPress

Note: Customizing your WordPress theme involves editing it’s different files which may need a little expertise with WordPress coding standard and development. It’s always better to backup your theme before editing. The recommended way to customize your theme is to do it locally (i.e. on a local WordPress installation rather than on your live site).

In order to show the modified date instead of the post published date, you need to edit some of your theme files. So, lets start, if you want to show the last updated date in your single (or full) post, just edit the single.php and look for the <?php the_date(); ?> or <?php get_the_date(); >.

If you’re not able to find the two functions, look for the template that has been called in the file to execute the loop. Try to figure out where these two functions are executing and replace it with the below code:

<?php the_modified_date('l, F j, Y', '<div class="the-modified-date">', '</div>'); >

The first parameter (highlighted in red) in the above function is the format of our date. That value there will display our date in this fashion: Sunday, May 12, 2013. Read more about Formatting WordPress date and time.

Value of the next parameter (highlighted in green) would be text or markup that should appear in the starting of our date. In the example code, I’ve added an opened HTML division tag since I wanted to put the date in a division.

Similarly, the next parameter (highlighted in blue) will carry value that should appear after the date. I’ve added a closing HTML div since I’ve placed and opened div tag in the start of the date. Check out the output I obtained by making the changes.

Result of the_modified_date() in WordPress

If you don’t want to show anything before or after the date, leave the parameters blank. Feeling confused? Read more about the_modifed_date function at WordPress codex.

You may repeat the process for the files page.php to show the modified date on pages.

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

WordPress automatically adds its current Version number to the head section of the themes. If you view the source of a WordPress-based website, you may find out the WordPress version it is using. Below given is the meta tag that carries that version informatio...
You can create two types of blogs with WordPress: WordPress.com hosted and self-hosted by installing WordPress on your web host. I’m not going to cover the difference between these two, but I’ll tell you how to find out owner’s information of WordPress blogs o...
You can learn how to start a WordPress site using the Internet as your primary teaching tool. WordPress is very easy to use, fortunately, even for dummies. Many an ebook can be found on this subject. You need woocommerce as an open-source e-commerce plugin tha...