Created
June 13, 2012 03:21
-
-
Save hissy/2921625 to your computer and use it in GitHub Desktop.
check the post is recently posted #WordPress
This file contains hidden or 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
/** | |
* Usage: if ( is_new() ) : echo 'NEW!'; endif; | |
* you can check if the post was posted within 30 days. | |
*/ | |
function is_new($day=30,$post=null){ | |
$term = $day * 24 * 60 * 60; | |
$post = get_post($post); | |
if ( !$post || is_wp_error( $post ) ) | |
return false; | |
$the_time = $post->post_date; | |
$time = strtotime($the_time); | |
$compare_time = time() - $term; | |
if($time > $compare_time){ | |
return true; | |
}else{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment