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.

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 has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

<?php
$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.