Presenting a warning for potentially outdated blog content

My older blog posts still seem to generate the odd bit of interest with people posting and asking for advice on potentially out-of-date topics (although one about Photoshop 7 crashing on startup is still one of my most popular posts!)

Some time ago, I decided to add a warning to these pages, to say something like “This post was originally published in 2011 and its contents may now be out-of-date.”

It’s implemented as a bit of PHP code in a WordPress widget:

$post_age = date('Y') - get_the_time('Y');
if($post_age > 1  ) { ?>

<div class="widgettitleb">
<h3 class="widgettitle">Warning</h3>
<div class="textwidget">
<p>This post was originally published in <?php the_time('Y'); ?> and its contents may now be out-of-date.</p>

<?php } ?>

Nothing particularly clever here, but it struck me that this might be useful for other WordPress site owners…

Leave a Reply