Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 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;
- }
- }
Add Comment
Please, Sign In to add comment