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

Possible Duplicate:
Add inline HTML to posts published within last 24hrs

I've been searching through the codex and Google and cannot not find a conditional tag based on age of post.

I'm looking to display a graphic overlay on top of a featured image if the post is less than three days old, for example.

Thanks very much.

share|improve this question

marked as duplicate by toscho Oct 2 '12 at 23:11

This question was marked as an exact duplicate of an existing question.

$today = date('r');
$articledate = get_the_time('r');
$difference = round((strtotime($today) - strtotime($articledate))/(24*60*60),0);
if ($difference >= 3) { ?>
this is a three day old post
<?php } ?>

the 3 in if ($difference >= 3) { ?> is 3 days old, you can change that to whatever you want. How I could do it, is add a css class to include the image.

share|improve this answer

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