Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Display the Last Updated Date of Your Posts in WordPress

Do you want to display the last updated date for your posts in WordPress?

Some websites update their posts regularly. Showing when each post was updated makes sure your readers don’t miss any content, helps build trust, and builds authority to boost SEO rankings.

In this article, we will show you how to display the last updated date of your posts in WordPress.

How to Display the Last Updated Date of Your Posts in WordPress

Why Display the Last Updated Date of Your Posts in WordPress?

When visitors view a post or page on your WordPress blog, your WordPress theme will show the date when the post was published. This is fine for most blogs and static websites.

However, WordPress is also used by websites where old articles are regularly updated. In these publications, it is important to display the date and time the post was last modified.

For example, on WPBeginner, we regularly update our tutorials and show the ‘last updated’ date on each post. If we only displayed the published date, our readers would skip the post, assuming the information is out of date.

Example of Showing the Update Date of a Post

Another example is news websites. They often update old stories to show new developments, add corrections, or insert media files. If they only showed the published date, then their users would miss those updates.

Additionally, Google and other search engines like to rank the most up-to-date information. Displaying your updated date helps Googlebot and others know when the post was last touched.

Having said that, let’s take a look at how you can easily display the last updated date for your posts in WordPress.

Video Tutorial

Subscribe to WPBeginner

If you prefer a written tutorial, then please continue reading the guide below.

How to Display the Last Updated Date of Your Posts in WordPress

This tutorial requires you to add code to your WordPress files. If you haven’t done this before, then we recommend you take a look at our guide on how to copy and paste code in WordPress.

Method 1: Showing Last Updated Date Before Post Content

We are going to be using WPCode for this tutorial, as it is the safest and easiest way to add custom code to WordPress.

Editing your site’s core WordPress files can be dangerous because even small mistakes or typos can break your site. So, we recommend you use WPCode to add any code snippets.

First, you will need to install and activate the free WPCode plugin. For more information, see our step-by-step guide on how to install a WordPress plugin.

Once the plugin is activated, navigate to Code Snippets » Add Snippet in your WordPress dashboard. Search for ‘last updated date,’ and hover your mouse over the result titled ‘Display the Last Updated Date.’

The code checks to see if a post’s published date and last modified dates are different. If they are, then it displays the last modified date before the post content. (This is the way we do it here at WPBeginner.)

Next, you can just click the ‘Use Snippet’ button.

WPCode searching for a snippet by name

Next, you will see the ‘Edit Snippet’ screen. WPCode has already configured the snippet for you.

All you have to do is toggle the switch to ‘Active’ and click ‘Update’ when you’re ready.

WPCode edit snippet page and activate code

Because the code snippet will display the updated date using your site’s body text styles, you can add custom CSS to style the appearance of the last updated date. Here is a little CSS snippet that you can use as a starting point:

.last-updated {
    font-size: small;
    text-transform: uppercase;
    background-color: #fffdd4;
} 

This is how it looks on our demo WordPress website.

Additionally, if you’re an advanced user and feel comfortable doing so, you can add the following to your theme’s functions.php file.

Just connect to your website via FTP or through your WordPress hosting file manager and find the file in your site’s /wp-content/themes/yourthemename/ folder.

$u_time          = get_the_time( 'U' );
$u_modified_time = get_the_modified_time( 'U' );
// Only display modified date if 24hrs have passed since the post was published.
if ( $u_modified_time >= $u_time + 86400 ) {

	$updated_date = get_the_modified_time( 'F jS, Y' );
	$updated_time = get_the_modified_time( 'h:i a' );

	$updated = '<p class="last-updated">';

	$updated .= sprintf(
	// Translators: Placeholders get replaced with the date and time when the post was modified.
		esc_html__( 'Last updated on %1$s at %2$s' ),
		$updated_date,
		$updated_time
	);
	$updated .= '</p>';

	echo wp_kses_post( $updated );
}

Method 2: Adding Last Updated Date in Theme Templates

You can also display the updated date in place of the published date, or just below it.

This method requires you to edit specific WordPress theme files. The files you need to edit will depend on the theme you are using.

Many WordPress themes use their own template tags to show post metadata like date and time. Other themes use content templates or template parts. Simpler themes will use single.php, archive.php and other template files to show content and meta information.

You need to look for the file that contains the code responsible for displaying the date and time. You can then either replace that code with the following code or add it right after your theme’s date and time code.

$u_time = get_the_time('U'); 
$u_modified_time = get_the_modified_time('U'); 
if ($u_modified_time >= $u_time + 86400) { 
echo "<p>Last modified on "; 
the_modified_time('F jS, Y'); 
echo " at "; 
the_modified_time(); 
echo "</p> "; } 

You can delete lines 6 and 7 if you don’t want to display the time the post was updated.

This is how it looked on our demo site. With the Twenty Twenty-One theme, we added the code snippet to the template-tags.php file inside the inc folder.

Preview of Displaying Update Date by Editing Template

How to Manage the Last Updated Date of Your Posts in WordPress

Now that we have added the last updated date for each post, it will automatically update every time you make a change to any post. But what if you’re only making a small correction rather than a full update, such as fixing a spelling mistake or adding a tag?

For small changes, it is usually best to leave the modified date unchanged from an SEO perspective. Your readers will then see the date when the last major update was made to the post.

Here are a few plugins that let you update a post without changing the modified date.

Method 1: Using the Limit Modified Date Plugin

First, you need to install and activate the Limit Modified Date plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Note: This plugin has not been updated recently. However, we tested it with the latest version of WordPress and it is still working.

Upon activation, you will see a new checkbox when editing posts. It is labeled ‘Don’t update the modified date’.

Checkbox Added by Last Updated Date

When you do a minor update to a post, simply check that box and the modified date will not be changed.

AIOSEO also known as All in One SEO is the best WordPress SEO plugin on the market. It helps you improve search rankings without learning complicated jargon, so you can increase your website traffic.

You can learn more in our guide on how to set up All in One SEO for WordPress correctly.

If you’re already using AIOSEO to improve your search engine rankings, then you can use it to manage the modified date of your posts as well.

Upon activation, you will find a new checkbox when editing posts, labeled ‘Don’t update the modified date’. You can check the box when making minor changes to a post.

This is useful when simply fixing typos or simple mistakes, and you can uncheck the box when making changes that you want your readers and search engines to know about.

Checkbox Added by AIOSEO

We hope this tutorial helped you learn how to display the last updated date of your posts in WordPress. You may also want to learn how to speed up WordPress performance or check out our list of proven tips to increase your blog traffic.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

148 CommentsLeave a Reply

  1. Jamie Brower

    Can you please tell me how to post the modified date AFTER the content. I tried using a in the footer.php but then it just displays before the content AND in the footer. I would just like the footer to display.

  2. Daniele

    Thanks guys, it works like a charm! A so so cool tip!

    If you want to add the last modified ONLY ON POSTS, that works for me (I’m Italian and I edited it not showing the hour and modified the date order):

    function wpb_last_updated_date( $content ) {
    $u_time = get_the_time(‘U’);
    $u_modified_time = get_the_modified_time(‘U’);
    if ($u_modified_time >= $u_time + 86400) {
    $updated_date = get_the_modified_time(‘d F Y’);
    $updated_time = get_the_modified_time(‘H:i’);
    $custom_content .= ‘Articolo aggiornato il ‘. $updated_date . ”;
    }
    if(is_single()){
    $custom_content .= $content;
    return $custom_content;
    }
    return $content;
    }
    add_filter( ‘the_content’, ‘wpb_last_updated_date’ );

    • David Aguirre

      Dude, this is gold, I don’t know why anyone has thanked you before.
      Thank you :D

    • PET

      Yeah, good stuff! Thanks bro!

  3. David

    I have applied above all settings on my website and its working fine.

    But I have one question that when two dates shown above content then which date will be shown in google search engine result page? Please provide answer because I have done all this only for showing last update date in google search engine result page.

  4. ahmed

    i like this it is very good and easy to install with genesis child theme function.php thank you

  5. Vishal Mukherjee

    Hi,
    Added the following code to functions.php

    function wpb_last_updated_date( $content ) {
    $u_time = get_the_time(‘U’);
    $u_modified_time = get_the_modified_time(‘U’);
    if ($u_modified_time >= $u_time + 86400) {
    $updated_date = get_the_modified_time(‘F jS, Y’);
    $updated_time = get_the_modified_time(‘h:i a’);
    $custom_content .= ‘Last updated on ‘. $updated_date . ‘ at ‘. $updated_time .”;
    }

    $custom_content .= $content;
    return $custom_content;
    }
    add_filter( ‘the_content’, ‘wpb_last_updated_date’ );

    Works fine for posts but … the same is displayed in Pages also.
    I want it only for post. or if pages then at a different place eg End og the page article.

    Best Wishes
    Vishal Mukherjee

  6. Victor Step

    Thank you for the code.
    However, there is a common problem that Google pulls the date of the embedded youtube video instead of the updated blog post date. In your case, I see that the search results do in fact show the correct date, and not the embedded video’s upload date. How did you achieve this? Thank you.

  7. RUWAN

    hello, I want only show updated date like your website, not both(updated and published date), when I add your code to site then its shows that both dates, please guide me to show only that updated date. thanks

  8. Ludwig Sörmlind

    Thank you for this post, I tried it and it works like a charm. I went for the site-specific plugin-option.

  9. Ebuka

    Thanks a lot it worked perfectly. but for the custom CSS only the “text-transform” worked on my theme. Other CSS like; color, text-weight, background-color etc. did not work. Please is there any possible way around it?

  10. peter

    hi syed ,am peter. the code work on my theme, but when i tried to add css style , i mean this code .last-updated {
    font-size: small;
    text-transform: uppercase;
    background-color: #fffdd4;
    }

    my site goes blank. please what do i do to restore my website…

  11. Steve W

    Thank you for this tip. I actually turned it into a shortcode so that it only shows up where I want it, and not on every page or post. [last_updated]

  12. Velyz Zhang

    Hi,
    Actually the code is work, but the result showing some numbers before “last update”

    1494555840LAST UPDATED ON JUL 9, 2017

    Every single post that I updated showing different numbers like that. Any one can help me?

    Thank you

  13. mathhew

    Can you please explain how to apply it for genesis framework. i tried it but it didn’t worked

  14. Adarsh Sahu

    Hey I just tried this method it worked fine for me but the problem is that now my post is not showing any date in google search please help me i also want to show last updated date in Google search when anyone searches my content.

  15. Filip

    Hi
    The code work great, thank you!
    Can you tell us how to edit published time and add Published by “author” like in your images?

  16. Chuks Ibe

    I tried using this for my blog but it is also showing the “Last Updated” in the latest post page and its making it look like Last updated is part of the post content.

    i need help to correct this thanks.

  17. Rui Oliveira

    Hi,

    I tried this on my website and it didn’t worked.

  18. Gaston

    Hi, i want to show last update date/time but of the entire web. How can i do this?

  19. Andy Trigg

    By the way I preferred not to have the time displayed, which I think is completely unecesssary so I deleted the following –
    at ‘. $updated_time .’

    I hope I did it right, it seems to work OK.

  20. Andy Trigg

    Excellent. This works great on my site. I too update articles all the time. Constantly improving them. I’m just completely rewriting and improving every article from day 1. Now instead of it showing my article is 10 years old people can see it has recently been updated.

  21. vishnu narayan v

    This adds a new section showing modified date, but I would like to show updated date instead of published date as you have done in wpbeginner.

    i would also like to know will this preserve seo and shows updated date in search engines??

    • Paul

      Yes I’d like to know re above.

      Especially the SEO impact of removing the original publication date.

      Thanks!

      – Paul

  22. Jason G.

    One question I have: After pasting in the function in the article, I noticed that only my home page displayed the updated date / time. What if I do not want it to run on the home page? I tried adding an additional condition, ! is_home(). That did not work as it still showed up. Is there a way to only display this on posts (and not on any pages). Nothing has worked so far. Thanks for any help!

    • WPBeginner Support

      Hi Jason,

      You can try the second method and add the code directly to each template where you want the updated date to be displayed.

      Admin

      • J M Das

        This plugin works. But, Last Updated is showing in the Home Page also. How to add the code to the Post Template alone? Thanks for help

    • samsor ithnin

      This working on me

      function wpb_last_updated_date( $content ) {
      $u_time = get_the_time(‘U’);
      $u_modified_time = get_the_modified_time(‘U’);
      if ($u_modified_time >= $u_time + 86400) {
      $updated_date = get_the_modified_time(‘j F, Y’);
      $updated_time = get_the_modified_time(‘h:i a’);
      $custom_content .= ‘Last updated on ‘. $updated_date . ‘ at ‘. $updated_time .”;
      }

      if(is_single()){
      $custom_content .= $content;
      return $custom_content;
      }
      return $content;
      }
      add_filter( ‘the_content’, ‘wpb_last_updated_date’ );

      • Green Yang

        @SAMSOR ITHNIN

        You are the man! The correct solution for show it only on posts exclude pages.
        Good if(is_single()){ way, thanks!

  23. SHELLEY R ZUREK

    If you update the post, will it go out in RSS feed again? I assume no?

  24. Roger

    The code that you display in this article shows the last updated date only but with no text explaining what that displayed date is in the post. It shows it like this:

    March 4th, 201701:29

    That is not very useful to my readers. Why won’t it display the $custom_content of line 7 of the code?

    • WPBeginner Support

      Hi Roger,

      Thanks for pointing this out. We have updated the article, please try the new code.

      Admin

  25. Matus

    I’ll be really grateful, if you could update your post about showing Related articles below posts. Or maybe recommend me plugin you’re using right now :)

  26. Ashoksinh Gohil

    Sorry but after used i find that if your article not updated that it shows blank, i.e not shows the date of published article
    it shows only when article updated or modified otherwise shows blank

  27. Ashoksinh

    Is SEO Shows This Modified Date ?

  28. Markus Martin

    My theme uses the wordpress default date in its theme and these modifications don’t work. Any help?

  29. Mohan Manohar Mekap

    Nice code and nice explanation. It is implemented on my site mohanmekap.com and working nicely, I have been seaching this code for internet though know it from wordpress codex but the instructions given here absolutely help for me kudos.

  30. Karan

    Hello WPBeginner Team,

    Can you please state your SEO point of view about displaying last updated date instead of published date?
    I have just successfully applied the changes and my blog posts are showing last updated date.

    What would be your opinion? Is it better to show last updated rather than published?

    Thank You,
    Karan

  31. Hardhik

    Hi Buddy,
    If I am not wrong, I have to replace this code in index, single and page.php pages.

  32. Amar

    Hello sir ,

    I wanna know that is there any way to find out when a article was published first time ??

    • WPBeginner Support

      Most sites show the publish date instead of last updated date. However, if a site does not show it, then you can still try viewing the source code. They may or not have a meta tag for published date and time.

      Admin

  33. ld

    Can you recommend a plugin that accomplishes this?

    Also, if I simply type “Last updated on XXXX”, will search engines recognize this and give appropriate credit for the freshness of the content?

  34. Milt Klingsporn

    The plugin “Last Modified Timestamp” seems to get the same results. I added it to a widget in the footer. Now that date the page was updated is shown.
    And I didn’t have to enter any code in any of the files.

    • Hardhik K Chitalia

      Code is always better than plugin bro. Code will not slow down your site, but plugins will.

      • WPBeginner Support

        Not exactly true. Plugins are code too, and the functions file where users usually paste code also acts as a plugin.

        Admin

        • Roger

          Wow this is new. I always thought using code was better than adding a plugin any day. Guess I was wrong – at least to a certain extent. I will say tho that you really have to watch out installing slow or badly coded plugins because they have been proven to cause security issues, which is one big reason why I tend to stay away from them as much as possible.

  35. parvez

    I changed post date from created to modified,its working fine,How to show DESC order modiefied date posts on wordpress.

    right now order of posts based on posted date.

  36. ryan

    What if I still want to keep teh original publish date?

    Something like :

    Jan. 1, 2015, last edited | published on Dec. 15, 2014 by Ryan Hipp

    • Cezar

      Same Q here

    • Cezar

      Did you manage to add the code to show like in your example ?

  37. Gabrielle

    I’m using _s / Underscores theme, and in my inc/temlate-files.php
    have the all time functions, how to show only posted on or only updated on time?

  38. Sasanga

    Why you are using this type of long code?

    We can use just “Last modified: “.

    Am I wrong?

    • Sameer Panda

      You want to change the text or the date?

      If you want to the modified date then, retrieve the date. And add text whatever you want before the date

  39. Sagar Patil

    is there any plugin available for last updated date.
    because im using ipin these and its hard to find code or related code in that.
    Thank You

    • Hardhik K Chitalia

      Last Modified Timestamp”

  40. Damith

    I have a question.

    Assume that I have written a post in 2014-01-01.

    Then, a person has copied enter article on 2014-02-01 and paste it own his blog.

    I updated one or two line in 2014-03-01.

    Then what happens?

    I mean, Is Google think my article is copied article and copied article is original article? ( Because now date of my article is 2014-03-01 and copied article date is 2014-02-01).

    Your reply is highly appreciated.

    • Govind

      i think google is smart enough…it also consider post indexing date along with published date.

  41. Nitin Maheta

    Users have to look for the code :  “<?php the_time(‘F jS, Y’);?>”

    NOT  “<?php the_modified_time(‘F jS, Y’);?>”

  42. TecBrat

    I did it a little bit differently, but it is the same concept. Thanks for pointing me in the right direction.
    For the twentyten theme, you edit the functions.php file, replacing the contents of the twenty_ten_posted_on() function with the following code:
    $verb=’Posted’;
    $postdate = get_the_date();

    $u_time = get_the_time(‘U’);
    $u_modified_time = get_the_modified_time(‘U’);
    if ($u_modified_time >= $u_time + 86400) {
    $verb=’Updated’;
    $postdate=get_the_modified_time(‘F jS, Y’);
    }
    echo ‘<span class="meta-prep meta-prep-author">’.$verb.’ on</span>
    <a href="’.get_permalink().’" rel="bookmark">
    <span class="entry-date">’.$postdate.'</span></a>’;

    echo ‘ <span class="meta-sep">by</span> <span class="author vcard"><a class="url fn n" href="’.get_author_posts_url( get_the_author_meta( ‘ID’ ) ).’"
    title="’.esc_attr( sprintf( __( ‘View all posts by %s’, ‘twentyten’ ), get_the_author() ) ).’">’.get_the_author().'</a></span>’;

  43. Barzrul

    This code doesn’t work for me. Had tried put in the theme but nothing showed up.

  44. Adriano

    The code is missing the most important part: else …

    the code compares the creation date of the update date, whichever is later then insert the date of update, but if the post does not have an update would not display anything, at least in my case.

    so it would be useful to add a:
    else the_time (‘F jS, Y’);

  45. Elena Nacci

    It’s me again:-) just another question: if I change to the “last updated on” date, the order in which my posts appear in my homepage will change?
    For ex. I publish a new article today, then later I update another older post, will the last updated post show as first in my home?
    Thanks again for your help!
    elena

    • WPBeginner Support

      No last updated post will not appear as the first post in your home page. Your home page will display posts by publish date not by update date.

      Admin

      • Elena Nacci

        Thanks a lot!

  46. Elena Nacci

    hello, I’ve tried to find the code in any of the files index.php, single.php, page.php, but there is no trace of it.
    Where else should I look for it? Does it depend on the wp theme?
    Thanks a lot,
    elena

    • WPBeginner Support

      Yes there are many different WordPress Themes, Theme Frameworks, and child themes. You should ask in the support forums for your theme and they will let you know how you can add your custom code to the theme.

      Admin

  47. GeraldoFilho

    This code doesn’t work for me, I search in codex and

    in Modified: at

    works.

  48. Arafin Shaon

    Hlw Syed I’ve been using genesis framework like you. So you know that genesis don’t have the following files and I guess this code snippet is not for gesesis. So it I’d be so nice of you if you kindly share the method you implemented with your child theme to show last modified date below post title instead of published date.

  49. Samedi Amba

    Just a small correction. It should be the genesis_before_post_content Hook, and NOT the genesi_before_content Hook, as I had earlier mentioned. ;-)

  50. jan geronimo

    Wow, you have many useful posts here on WordPress. You’ve forced my hand. I’m subscribing now to your feed. What a useful site you have here. I’m very impressed.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.