Guest User

Untitled

a guest
Oct 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. /**
  2. * Usage: if ( is_new() ) : echo 'NEW!'; endif;
  3. * you can check if the post was posted within 30 days.
  4. */
  5. function is_new($day=30,$post=null){
  6. $term = $day * 24 * 60 * 60;
  7. $post = get_post($post);
  8. if ( !$post || is_wp_error( $post ) )
  9. return false;
  10. $the_time = $post->post_date;
  11. $time = strtotime($the_time);
  12. $compare_time = time() - $term;
  13.  
  14. if($time > $compare_time){
  15. return true;
  16. }else{
  17. return false;
  18. }
  19. }
Add Comment
Please, Sign In to add comment