Notify of Old Post in WordPress


/ Published in: PHP
Save to your folder(s)

## Benefit
To notify visitors that the current post they are viewing is an old post. Suitable for Blog / Website that provide timely articles


Copy this code and paste it in your HTML
  1. <?php
  2. // Put inside Post Loop
  3.  
  4. $time_defined_as_old = 60*60*24*365; // A Year
  5.  
  6. if((date('U')-get_the_time('U')) > $time_defined_as_old) {
  7. 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>';
  8. }
  9.  
  10. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.