WordPress Hosting
Free Photos
WordPress Themes

How to display a disclaimer on posts older than one year

<? $ageunix = get_the_time('U'); $days_old_in_seconds = ((time() - $ageunix)); $days_old = (($days_old_in_seconds/86400)); if ($days_old > 365) { echo '<div class="disclaimer">DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.</div>'; } ?>
When you’re blogging, it can be a good idea to display a warning to your visitors stating that they are currently reading an old post which might not be up to date. Here’s an out-of-the-box solution to do it.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.