Skip to content

Instantly share code, notes, and snippets.

@nickberens360
Created October 26, 2016 13:49
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 nickberens360/51f9e753dc0fbd231c1aa5bfc2e734d3 to your computer and use it in GitHub Desktop.
Save nickberens360/51f9e753dc0fbd231c1aa5bfc2e734d3 to your computer and use it in GitHub Desktop.
wp if post is older than published date
//Functions file
function is_old_post($days = 5) {
$days = (int) $days;
$offset = $days*60*60*24;
if ( get_post_time() < date('U') - $offset )
return true;
return false;
}
//Usage
if ( is_old_post(10) ) {
// do something if the post is old
} else {
// do something if the post is not old
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment