Warning Readers About Out-Of-Date Content

« »

When I redesigned my blog for the new year, I omitted a feature that had been there for the past several years: a prominent warning about out-of-date content. Elizabeth Naramore asked me on Twitter if I had removed it, and she said that she felt it was useful to warn readers that content was out of date.

Warning readers that content may be out of date helps them because it makes obvious that an article is dated, and allows them to apply more stringent critical reading skills to the article than they might otherwise have applied. Technical articles can go out of date quickly, and bloggers should do what they can to help readers identify potentially troublesome content.

Part of my reason for removing it is that a date-based warning system presents little ability to actually identify posts that are “always current.” For example, my most popular post is nearly two years old and is as current as the day I wrote it. I didn’t want to warn readers that it might be out of date when in fact I knew it wasn’t.

However, I solved this problem with a small bit of code in my WordPress template:

$custom = get_post_custom();
$date = the_date('F j, Y', null, null, false);

$datetime = strtotime($date);
$two_years_ago = (time() - (365 * 24 * 60 * 60) * 2);
if($datetime < $two_years_ago && !(isset($custom['always_current']) && (bool)$custom['always_current'][0])) {
 // Do "out of date" box here.


This code is simple but completely solves the problem. First, it marks all posts two years or older as out of date. Second, it supports a flag that I can set saying a post is “always current”. This flag is set manually in the “Custom Fields” area of a post in WordPress.

If you’re a blogger I recommend that you offer an out of date warning to your readers. Your readers will thank you!

Brandon Savage is the author of Mastering Object Oriented PHP and Practical Design Patterns in PHP

Posted on 2/8/2013 at 1:03 pm
Categories: Best Practices, Blogging

Hikari wrote at 4/9/2013 7:43 pm:

lol I was just gonna suggest adding a backend setting to overwrite date comparison and set articles whose content should never get old to not show the message :p

I don’t like that warning, it just bloats the UI. Just make sure to put post date in the top of the article.

And don’t add the code directly in the theme :P Add a function to functions.php, to do the magic and return true if it should be printed!

« »

Copyright © 2024 by Brandon Savage. All rights reserved.