Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@senlin
Created August 13, 2012 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senlin/3344853 to your computer and use it in GitHub Desktop.
Save senlin/3344853 to your computer and use it in GitHub Desktop.
Display a message on older posts
<?php //display a message on older posts
function older_post_message () {
$posted = get_the_time('U');
$current = current_time('timestamp');
//Convert difference in seconds to days
$diffTime = ($current - $posted) / (60*60*24);
if($diffTime > 365){
echo '<div class=older-post-message>' . __('This post was written more than a year ago and <em>might</em> not be entirely accurate anymore.', 'text-domain') . '</div><br />';
}
}
add_action('get_template_part_content','older_post_message');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment