Are you looking for a way to display a message to your users to notify them when a post over an year old? While there’s probably a plugin for this, we have created a quick code snippet that you can use to notify readers of old posts in WordPress.
Instructions:
All you have to do is add this code to your theme’s single.php file.
<?php $time_defined_as_old = 60*60*24*365; // A Year if((date('U')-get_the_time('U')) > $time_defined_as_old) { echo '<div class="notice"><strong>Notice</strong><br />This article is published more than one year ago. Information in this article might be irrelevant with current situation</div>'; } ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 43 photography themes for WordPress and how to create a contact form in WordPress.
Is there a way to have it notify in admin instead of live if a post has reached a certain age?
How are you thinking to display this? like something within the posts columns.
Exactly, just an indicator next to the post that it hasn’t been updated in X number of months,days.
Also, it may be beneficial to have items in “Right Now” on the dashboard. older than 6 months, 1 year, etc.
Hi Zach I think you would need to have something on the dashboard, if the site was like wpsnipp.com I have over 460 posts as a result I would never see the icon unless I viewed very old posts. Ill look into the idea see if I can’t post a new snippet, great idea though.
The exact same thing would occur with us as well. That’s why I was saying adding it to “right now” might work.
[…] This post was mentioned on Twitter by HTMLfrp, WPSNIPP. WPSNIPP said: #wordpress Notify readers of old posts http://bit.ly/g5vVcB #blog please RT 🙂 […]
WordPress Notify readers of old posts – wpsnipp.com WordPress code snippets for your blog…
Adding this to your wordpress theme will display a message to your visitors to notify them when a post is over a year old….