<?php/** * Source & Inspiration: * https://wpengineer.com/1913/if-post-is-older-than/ * * If a post has not been updated within the last 60 days place a notice to alert the reader * For placement in functions.php of your theme or child theme. */functionjd_is_old_post($days=60){$days=(int)$days;$offset=$days*60*60*24;if(get_post_modified_time()<date('U')-$offset)returntrue;returnfalse;}?>
<?php/** * If post is older than 60 day's this will post a notice to the reader * For placement within the loop of the post. */if(jd_is_old_post()){echo'<div class="old-post-notice">';echo'<p><strong>This page has not been updated in 60 days. The information below may be outdated.</p></strong>';echo'</div>';}?>
Comments (1)
Joseph Dickson
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.