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; ?>
Related Posts:
About this entry
You’re currently reading “Return most recent post by date range,” an entry on Hariadi.Org
- Published:
- 01.04.08 / 10am
- By:
- Hariadi Hinta