The following code shows the posts made the last 30 days.
Every post I have it has a meta_key named expiring with a meta_value of 2011-10-22 for example.
In my case, I want to remove the post_date and find what posts are near to be expired. For example, today we have 2011-10-18 and I want to show all the posts that have dates from today (18) until 2011-10-21. That means 3 days after today.
Tomorrow 2011-10-19 it must show posts that may also expire in 2011-10-22.
This is how I get the value of the meta_key get_post_meta($post->ID, 'expiring', true);
This is the function I tried to edit.
<?php
function filter_where($where = '') {
//posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts('post_type=post&posts_per_page=10&order=DESC');
while (have_posts()): the_post(); ?>
<li><?php the_title(); ?></li>
<?php
endwhile;
wp_reset_query();
?>
Thank you for any help.
I don’t know if I understand the problem properly, but it seems you want to have this in your function:
Sort on expire_date, rather than post date, and take everything where the expire date is not later than 3 days in the future.