WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
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


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.