Return most recent post by date range
UPDATED: This trick not work with paging. Go to another trick
Want to limit the number of posts on your front page by a date range? For example, display most recent posts for the last 30 days? This works perfectly..
Open index.php template file. Changed this code from:
<?php while (have_posts()) : the_post(); ?>
to:
<?php while (have_posts()) : the_post(); ?>
<?php
$mylimit=30*(60*60*24);
if ( (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') * 3600) ) < $mylimit)
{
?>
and this code from:
<?php endwhile; ?>
to:
<?php } ?>
<?php endwhile; ?>
This entry was posted on Tuesday, April 1st, 2008 at 10:06 am and is filed under How-To, WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

