strtotime results in a timestamp (number of seconds since January 1, 1970, while post_date isn’t. You’re comparing apples to oranges.
You should convert post_date also with strtotime.
Peter
I’ve tried this, and the functionality still isn’t working properly. Looking at the following example:
Return posts for various date ranges:
<?php
//based on Austin Matzko's code from wp-hackers email list
function filter_where($where = '') {
//posts in the last 30 days
//$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
//posts 30 to 60 days old
//$where .= " AND post_date >= '" . date('Y-m-d', strtotime('-60 days')) . "'" . " AND post_date <= '" . date('Y-m-d', strtotime('-30 days')) . "'";
//posts for March 1 to March 15, 2009
$where .= " AND post_date >= '2009-03-01' AND post_date < '2009-03-16'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
?>
How can I take what I have above and use the same functionality from this example in an if statement to add something extra if the date range is true? I still can’t get it quite right…
Found the format I needed:
<?php if (strtotime($post->post_date) > strtotime('-4 days')): ?> <b>NEW</b> <?php endif; ?>