You can’t really check post_date
in pre_get_posts
, because, well, the action fires before (pre_
…) the posts have actually been fetched (…get_posts
). 🙂
But, you can use $query->set()
to add date parameters to the query. This is taken from an example in the WP_Query()
Codex entry:
<?php
function wpse54142_filter_pre_get_posts( $query ) {
if ( is_feed() ) {
$today = getdate();
$query->set( 'year', $today['year'] );
$query->set( 'monthnum', $today['mon'] );
$query->set( 'day', $today['mday'] );
}
return $query;
}
add_filter( 'pre_get_posts', 'wpse54142_filter_pre_get_posts' );
?>