Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom field. I would like to change the text of that custom field after x days.

I want something like this:

if ( published post is more than 90 days old ) {
    echo "your post is more than 90 days old"; 
}
else {
    echo "your post is less than 90 days old";
}

Can anyone help me to achieve this?

Thanks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You shouldn't need to use a meta field for this logic.

In the loop $post->post_date holds when the post is published. From there you can determine if the date is 90 days old:

$datetime = strtotime($post->post_date);
if( $datetime < ( time() - ( 60 * 60 * 24 * 90 ) ) ) {
    echo "> 90 days old"
} else {
    echo "< 90 days old"
}
share|improve this answer
    
Thanks Mr.Brady –  Giri Aug 10 '11 at 10:07
    
ROFL at the MR.Brady. Inside joke. –  Brady Aug 10 '11 at 14:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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