Created
October 26, 2016 13:49
-
-
Save nickberens360/51f9e753dc0fbd231c1aa5bfc2e734d3 to your computer and use it in GitHub Desktop.
wp if post is older than published date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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