Wordpress Tip: Easy Notification for an Updated Post

How many times do you write a blog post and then a few hours later, need to make an update to it? Probably often enough that you know exactly what I am talking about.
Some blogs put a simple paragraph like this at the either the top or bottom of the original post. Using this as your primary notification fails in terms of it’s usability for your readers.
While this is probably the easiest and most common way it’s done - you also need a better way to easily alert your returning readers that this post is now “updated” with new information.
A Simple Notification
Luckily, the Wordpress Codex offers a little known function called get_the_modified_time. When we combine that function along with the get_the_time function, we can create a powerful way to show a post has been updated - automatically.
The code below checks the modified time of the post against the published time of the post + 1800 seconds (a half hour), and if the modified time is later, it displays the text ‘Updated’.
<?php
if ($get_the_modified_time('U') > (get_the_time('U') 1800)) {
echo " <span class='updated-post'>Updated</span>";
};
?>
Feel free to change the 1800 variable above to any amount of seconds you feel comfortable with. For example, setting the variable to 3600 would show ‘Updated’ if the post was changed 1 hour and 20 minutes after the post was published, but it wouldn’t show any notification if it was updated less than an hour after it was originally published. For an easy way to convert seconds to hours, either though an online interface or through a PHP function, visit cKorp.net.

Add a little creative CSS, you can turn this into anything. Here is an example to help get you started.
span.updated-post {
font-size:10px;
text-transform:uppercase;
font-family:arial, verdana, sans-serif;
background:#7CCC5C;
padding:2px;
color:#FFFFFF;
}




June 16th, 2009
10:52 am
This tweak is just great! I’ve been looking for a way on how to easily notify my users regarding immediate updates and this just solves everything. Thanks man!