X

Notify readers of old posts

Beaver Builder review

Adding this to your wordpress theme within the loop will display a message to your visitors to notify them when a post is over a year old.



Code Snippet:


<?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>';
}
?>

Comments  Leave a Reply

  1. Is there a way to have it notify in admin instead of live if a post has reached a certain age?

    1. How are you thinking to display this? like something within the posts columns.

      1. 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.

        1. 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.

        2. The exact same thing would occur with us as well. That’s why I was saying adding it to “right now” might work. 

  2. Tweets that mention Wordpress Notify readers of old posts – wpsnipp.com Wordpress code snippets for your blog -- Topsy.com February 16, 2011 at 3:45 pm

    […] This post was mentioned on Twitter by HTMLfrp, WPSNIPP. WPSNIPP said: #wordpress Notify readers of old posts http://bit.ly/g5vVcB #blog please RT 🙂 […]

  3. 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….

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!