0

I have this code

<?php if( date('U') - get_the_time('U', $post->ID) < 24*60*60 ) : ?>New Post<?php endif; ?> 

for posts that are under 24 hours old I want to alter the code for it to display Old Post if it's over 24 hours

0

Just flip the "less than" < to "greater than" >:

<?php if ( date( 'U' ) - get_the_time( 'U', $post->ID ) > DAY_IN_SECONDS ) : ?>Old Post<?php endif ?>

http://codex.wordpress.org/Easier_Expression_of_Time_Constants

| improve this answer | |
  • I added the code and it's not showing but the posts that have been made in 24 hrs work with the image – Brittany Quake Feb 9 '15 at 7:32
  • Can you post the code that's showing the image? – TheDeadMedic Feb 9 '15 at 11:29
  • Never mind it was taking time to update – Brittany Quake Feb 9 '15 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.